From nobody Tue Oct 04 16:29:39 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MhjpW5PyFz4fCFF; Tue, 4 Oct 2022 16:29:39 +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 4MhjpW4W7Lz44cj; Tue, 4 Oct 2022 16:29:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664900979; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YKrYlOB6P140Sbn5FgDv5OonbkjKPiqVmd+Emk1VbN0=; b=v4TvP8ErMIYRy/4uE0kms483gGdqHSxHCcLlr0Gw7Agwtj6HfOzuzJ8VYZoaWFkxA78sMm ZFavrNmbkFto0YMX/Ne7zcp6RWj27dU0dX8UaeMsbAGVkIMUsf1Cp5v2VWqCSPouS/J/il 3oEz3WjyfRmZYcNibHmQ0pN0VrIuAPNSKezSOoP0j3OfOt8i2Tbj6RkL9oIdyvH/1iHUqE YigquuGczziKmjhpqNL+sCyMew+hNhmc3L2As400TlbKo/E3fE1kIr1aY++B9+QobyvfBE KOE+DEGSVLyrrR/rR4jYVH5JyJnGKsW0sSn4UXSNnD1KJTPP/8qFAcfK/1JRJw== 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 4MhjpW3W5HzcbF; Tue, 4 Oct 2022 16:29:39 +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 294GTdQu049843; Tue, 4 Oct 2022 16:29:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 294GTdxr049842; Tue, 4 Oct 2022 16:29:39 GMT (envelope-from git) Date: Tue, 4 Oct 2022 16:29:39 GMT Message-Id: <202210041629.294GTdxr049842@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Leandro Lupori Subject: git: c74c77531248 - stable/13 - powerpc/pseries: Allow radix pmap in pseries for ISA 3.0 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: c74c77531248c69b9b53f18c00d1cfcd09100d18 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664900979; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YKrYlOB6P140Sbn5FgDv5OonbkjKPiqVmd+Emk1VbN0=; b=AwRcSv6kGc7ylhCxU5xCCSQ95WxtRZsKELjTp35XEWKP6spyB3ZV+3QrvYgqBExvJwb8sd ksnTmq+z6x+yCbPUwzTIWV266f3DH4U6sYJ0jCFq1JVpmmm7bmJA0pXudpvugeNQcxE1fX F3vxAST2b/sotTbh54LMX6Rud7pQfMLXH83OIn7j0TteyIlgBuqa9LDHgNeBiei2yOtVPH P/o4/tRoz8qyLyCbGlNYhSPA1DvWE2irrLREqy0TUkAyk6B+CW3Zsiv2Y3NTBg2SJKw8nA h+tU1lpI8T6vaTGAj7W//XTDikgVnO17wLw22bnAFBbfMcq4qzgIbSc1wMWKBQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664900979; a=rsa-sha256; cv=none; b=PGdNUlM4YWaya8vEVBI1ibpkCgnE4vuk9r7Ri9jZ5xqFro0dzTKDudLZetDauredZy1m9d GoL8R2A8Ya78IdngmFMMr1w6WrB4lGExYeeIU7UNPOWibMsGVNNqmfGbKKDx+XcjOliH/Y vsvZZFTfbSZIhHQtyZR0SC+iYLy6TWp3S7AqYYq8gX2y7LlyCqO/BmSqVboyKXjnsofbhD vzQr2IxwLTTxu7lQjvYmdD16Kv5N6lWPzgTxLvmT7umcrc9Qouww0mskYWRa0w2/vVJwel Zq0myYILlrvzXqht3AXE4EXaS1QiA6HXqQ9xg3EkFBpqqvSiGxLDnKoDX4t2Gg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by luporl: URL: https://cgit.FreeBSD.org/src/commit/?id=c74c77531248c69b9b53f18c00d1cfcd09100d18 commit c74c77531248c69b9b53f18c00d1cfcd09100d18 Author: Justin Hibbits AuthorDate: 2021-08-12 00:03:27 +0000 Commit: Leandro Lupori CommitDate: 2022-10-04 16:24:14 +0000 powerpc/pseries: Allow radix pmap in pseries for ISA 3.0 ISA 3.0 allows for nested radix translations with minimal to no involvement of the hypervisor. This should make pseries signficantly faster on POWER9 pseries instances, as fewer hypercalls are needed to manage pmap now. Relnotes: yes (cherry picked from commit 5ae48eb998ad5d41118d2df62cf28b92d6864e24) --- sys/conf/options.powerpc | 2 +- sys/powerpc/aim/mmu_radix.c | 53 +++++++++++++++++++++++++++---------- sys/powerpc/pseries/phyp-hvcall.h | 10 +++++++ sys/powerpc/pseries/platform_chrp.c | 3 ++- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/sys/conf/options.powerpc b/sys/conf/options.powerpc index 857fa8091f4a..0885ccde15b5 100644 --- a/sys/conf/options.powerpc +++ b/sys/conf/options.powerpc @@ -23,7 +23,7 @@ POWERMAC opt_platform.h PS3 opt_platform.h MAMBO POWERNV opt_platform.h -PSERIES +PSERIES opt_platform.h PSIM QEMU opt_platform.h diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c index 77d15b086527..f77c1f5c8da4 100644 --- a/sys/powerpc/aim/mmu_radix.c +++ b/sys/powerpc/aim/mmu_radix.c @@ -25,6 +25,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "opt_platform.h" + #include __FBSDID("$FreeBSD$"); @@ -84,6 +86,9 @@ __FBSDID("$FreeBSD$"); #include #include +/* For pseries bit. */ +#include + #ifdef INVARIANTS #include #endif @@ -93,6 +98,7 @@ __FBSDID("$FreeBSD$"); #define PPC_BITLSHIFT_VAL(val, bit) ((val) << PPC_BITLSHIFT(bit)) #include "opt_ddb.h" + #ifdef DDB static void pmap_pte_walk(pml1_entry_t *l1, vm_offset_t va); #endif @@ -779,8 +785,10 @@ mmu_radix_tlbiel_flush(int scope) static void mmu_radix_tlbie_all(void) { - /* TODO: LPID invalidate */ - mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + if (powernv_enabled) + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + else + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_LPID); } static void @@ -2021,11 +2029,14 @@ mmu_radix_early_bootstrap(vm_offset_t start, vm_offset_t end) */ if (isa3_pid_bits == 0) isa3_pid_bits = 20; - parttab_phys = moea64_bootstrap_alloc(PARTTAB_SIZE, PARTTAB_SIZE); - validate_addr(parttab_phys, PARTTAB_SIZE); - for (int i = 0; i < PARTTAB_SIZE/PAGE_SIZE; i++) - pagezero(PHYS_TO_DMAP(parttab_phys + i * PAGE_SIZE)); + if (powernv_enabled) { + parttab_phys = + moea64_bootstrap_alloc(PARTTAB_SIZE, PARTTAB_SIZE); + validate_addr(parttab_phys, PARTTAB_SIZE); + for (int i = 0; i < PARTTAB_SIZE/PAGE_SIZE; i++) + pagezero(PHYS_TO_DMAP(parttab_phys + i * PAGE_SIZE)); + } proctab_size = 1UL << PROCTAB_SIZE_SHIFT; proctab0pa = moea64_bootstrap_alloc(proctab_size, proctab_size); validate_addr(proctab0pa, proctab_size); @@ -2172,12 +2183,20 @@ mmu_radix_proctab_init(void) htobe64(RTS_SIZE | DMAP_TO_PHYS((vm_offset_t)kernel_pmap->pm_pml1) | RADIX_PGD_INDEX_SHIFT); - mmu_radix_proctab_register(proctab0pa, PROCTAB_SIZE_SHIFT - 12); + if (powernv_enabled) { + mmu_radix_proctab_register(proctab0pa, PROCTAB_SIZE_SHIFT - 12); + __asm __volatile("ptesync" : : : "memory"); + __asm __volatile(PPC_TLBIE_5(%0,%1,2,1,1) : : + "r" (TLBIEL_INVAL_SET_LPID), "r" (0)); + __asm __volatile("eieio; tlbsync; ptesync" : : : "memory"); +#ifdef PSERIES + } else { + phyp_hcall(H_REGISTER_PROC_TBL, + PROC_TABLE_NEW | PROC_TABLE_RADIX | PROC_TABLE_GTSE, + proctab0pa, 0, PROCTAB_SIZE_SHIFT - 12); +#endif + } - __asm __volatile("ptesync" : : : "memory"); - __asm __volatile(PPC_TLBIE_5(%0,%1,2,1,1) : : - "r" (TLBIEL_INVAL_SET_LPID), "r" (0)); - __asm __volatile("eieio; tlbsync; ptesync" : : : "memory"); if (bootverbose) printf("process table %p and kernel radix PDE: %p\n", isa3_proctab, kernel_pmap->pm_pml1); @@ -2309,6 +2328,7 @@ mmu_radix_bootstrap(vm_offset_t start, vm_offset_t end) if (bootverbose) printf("%s\n", __func__); hw_direct_map = 1; + powernv_enabled = (mfmsr() & PSL_HV) ? 1 : 0; mmu_radix_early_bootstrap(start, end); if (bootverbose) printf("early bootstrap complete\n"); @@ -2323,8 +2343,10 @@ mmu_radix_bootstrap(vm_offset_t start, vm_offset_t end) mmu_radix_init_iamr(); mmu_radix_proctab_init(); mmu_radix_pid_set(kernel_pmap); - /* XXX assume CPU_FTR_HVMODE */ - mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + if (powernv_enabled) + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + else + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_LPID); mmu_radix_late_bootstrap(start, end); numa_mem_regions(&numa_pregions, &numa_pregions_sz); @@ -2351,7 +2373,10 @@ mmu_radix_cpu_bootstrap(int ap) } mmu_radix_init_iamr(); mmu_radix_pid_set(kernel_pmap); - mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + if (powernv_enabled) + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + else + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_LPID); } static SYSCTL_NODE(_vm_pmap, OID_AUTO, l3e, CTLFLAG_RD, 0, diff --git a/sys/powerpc/pseries/phyp-hvcall.h b/sys/powerpc/pseries/phyp-hvcall.h index 90f75807e56a..face804aff08 100644 --- a/sys/powerpc/pseries/phyp-hvcall.h +++ b/sys/powerpc/pseries/phyp-hvcall.h @@ -177,6 +177,16 @@ #define H_SET_MODE_RSRC_ILE 0x4 /* PAPR 2.8 / ISA 2.07 */ #define H_SET_MODE_RSRC_DAWR1 0x5 /* ISA 3.1 Future support */ +/* H_REGISTER_PROC_TBL identifiers. */ +#define PROC_TABLE_OP_MASK 0x18 +#define PROC_TABLE_DEREG 0x10 +#define PROC_TABLE_NEW 0x18 +#define PROC_TABLE_TYPE_MASK 0x06 +#define PROC_TABLE_HPT_SLB 0x00 +#define PROC_TABLE_GTSE 0x01 +#define PROC_TABLE_HPT_PT 0x02 +#define PROC_TABLE_RADIX 0x04 + /* pSeries hypervisor opcodes. */ #define H_REMOVE 0x04 #define H_ENTER 0x08 diff --git a/sys/powerpc/pseries/platform_chrp.c b/sys/powerpc/pseries/platform_chrp.c index 202ee059c528..f095e97edaf1 100644 --- a/sys/powerpc/pseries/platform_chrp.c +++ b/sys/powerpc/pseries/platform_chrp.c @@ -154,7 +154,8 @@ chrp_attach(platform_t plat) realmaxaddr = MAX(off, realmaxaddr); } - pmap_mmu_install("mmu_phyp", BUS_PROBE_SPECIFIC); + if (!radix_mmu) + pmap_mmu_install("mmu_phyp", BUS_PROBE_SPECIFIC); cpu_idle_hook = phyp_cpu_idle; /* Set up important VPA fields */