From owner-dev-commits-src-main@freebsd.org Wed Sep 8 11:43:32 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 943696796B4; Wed, 8 Sep 2021 11:43:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H4Kyr3nzlz4rsD; Wed, 8 Sep 2021 11:43:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6282B25353; Wed, 8 Sep 2021 11:43:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 188BhWBG084601; Wed, 8 Sep 2021 11:43:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 188BhWIL084600; Wed, 8 Sep 2021 11:43:32 GMT (envelope-from git) Date: Wed, 8 Sep 2021 11:43:32 GMT Message-Id: <202109081143.188BhWIL084600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Leandro Lupori Subject: git: 4f7c436548ea - main - powerpc64: fix radix on pseries TLB invalidation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: luporl X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4f7c436548ea1cc935c4f4b237693fbe8ed7939a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2021 11:43:32 -0000 The branch main has been updated by luporl: URL: https://cgit.FreeBSD.org/src/commit/?id=4f7c436548ea1cc935c4f4b237693fbe8ed7939a commit 4f7c436548ea1cc935c4f4b237693fbe8ed7939a Author: Leandro Lupori AuthorDate: 2021-09-08 11:37:11 +0000 Commit: Leandro Lupori CommitDate: 2021-09-08 11:37:11 +0000 powerpc64: fix radix on pseries TLB invalidation When running in a virtualized environment, TLB invalidations can only be performed on process scope, as only the hypervisor is allowed to invalidate a global scope, or else a Program Interrupt is triggered. Since we are here, also make sure that the register process table hypercall returns success. Reviewed by: jhibbits MFC after: 2 weeks Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D31775 --- sys/powerpc/aim/mmu_radix.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c index 8c3f6e2cf37a..50c658e58a4a 100644 --- a/sys/powerpc/aim/mmu_radix.c +++ b/sys/powerpc/aim/mmu_radix.c @@ -657,10 +657,10 @@ extern void bs_remap_earlyboot(void); #define PARTTAB_HR (1UL << 63) /* host uses radix */ #define PARTTAB_GR (1UL << 63) /* guest uses radix must match host */ -/* TLB flush actions. Used as argument to tlbiel_all() */ +/* TLB flush actions. Used as argument to tlbiel_flush() */ enum { - TLB_INVAL_SCOPE_LPID = 0, /* invalidate TLBs for current LPID */ - TLB_INVAL_SCOPE_GLOBAL = 1, /* invalidate all TLBs */ + TLB_INVAL_SCOPE_LPID = 2, /* invalidate TLBs for current LPID */ + TLB_INVAL_SCOPE_GLOBAL = 3, /* invalidate all TLBs */ }; #define NPV_LIST_LOCKS MAXCPU @@ -758,9 +758,11 @@ tlbiel_flush_isa3(uint32_t num_sets, uint32_t is) * and partition table entries. Then flush the remaining sets of the * TLB. */ - tlbiel_radix_set_isa300(0, is, 0, RIC_FLUSH_ALL, 0); - for (set = 1; set < num_sets; set++) - tlbiel_radix_set_isa300(set, is, 0, RIC_FLUSH_TLB, 0); + if (is == TLB_INVAL_SCOPE_GLOBAL) { + tlbiel_radix_set_isa300(0, is, 0, RIC_FLUSH_ALL, 0); + for (set = 1; set < num_sets; set++) + tlbiel_radix_set_isa300(set, is, 0, RIC_FLUSH_TLB, 0); + } /* Do the same for process scoped entries. */ tlbiel_radix_set_isa300(0, is, 0, RIC_FLUSH_ALL, 1); @@ -773,13 +775,10 @@ tlbiel_flush_isa3(uint32_t num_sets, uint32_t is) static void mmu_radix_tlbiel_flush(int scope) { - int is; - MPASS(scope == TLB_INVAL_SCOPE_LPID || scope == TLB_INVAL_SCOPE_GLOBAL); - is = scope + 2; - tlbiel_flush_isa3(POWER9_TLB_SETS_RADIX, is); + tlbiel_flush_isa3(POWER9_TLB_SETS_RADIX, scope); __asm __volatile(PPC_INVALIDATE_ERAT "; isync" : : :"memory"); } @@ -2200,9 +2199,15 @@ mmu_radix_proctab_init(void) __asm __volatile("eieio; tlbsync; ptesync" : : : "memory"); #ifdef PSERIES } else { - phyp_hcall(H_REGISTER_PROC_TBL, + int64_t rc; + + rc = phyp_hcall(H_REGISTER_PROC_TBL, PROC_TABLE_NEW | PROC_TABLE_RADIX | PROC_TABLE_GTSE, proctab0pa, 0, PROCTAB_SIZE_SHIFT - 12); + if (rc != H_SUCCESS) + panic("mmu_radix_proctab_init: " + "failed to register process table: rc=%jd", + (intmax_t)rc); #endif }