From nobody Mon Feb 9 22:19:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1596789532; cv=none; d=zohomail.com; s=zohoarc; b=Juptzpi2auVLAmL3QNDtxJMna08zFC4bnHg+iSZxOCHfcbuQhOf/0WZE2A6Ddqhi+/NoEzjZV7XLYzEtElrwTW7g9zar03uGDiFIK4VvahSwZI3wP1+k/PuyFiB0ZQ+UTNlHDXD8mJFHwbUz/aNfpJPkgI+KkQ1Sy6v3Fm86KeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596789532; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=grghbTorMo2hgj2afU9Vuwfl/p8cv6SzNIxp6754RNA=; b=hqr0dZr7TEe6PXIEP6R8mkLAl+O8ajsCPXbklKmtqPNNI5Ki4vdbw2DaaS0Qg3qJ3f30cWKat6TTmzqo0iVakpeWcxJfqvH70KJ68BxQR+SF05Dr0MAiFf87puz5rSnk8Ea2sphX8DulcAGi5yV9wojk03VYVqIxndRXytObfwM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1596789532539101.20909429994867; Fri, 7 Aug 2020 01:38:52 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k3xta-0006sZ-Me; Fri, 07 Aug 2020 08:38:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k3xtZ-0006sR-DY for xen-devel@lists.xenproject.org; Fri, 07 Aug 2020 08:38:33 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 076e7353-05c9-4c5a-854f-579ddf3fa160; Fri, 07 Aug 2020 08:38:32 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A0329B641; Fri, 7 Aug 2020 08:38:49 +0000 (UTC) X-Inumbo-ID: 076e7353-05c9-4c5a-854f-579ddf3fa160 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/7] x86/xen: drop tests for highmem in pv code Date: Fri, 7 Aug 2020 10:38:22 +0200 Message-Id: <20200807083826.16794-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200807083826.16794-1-jgross@suse.com> References: <20200807083826.16794-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Boris Ostrovsky , Thomas Gleixner Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" With support for 32-bit pv guests gone pure pv-code no longer needs to test for highmem. Dropping those tests removes the need for flushing in some places. Signed-off-by: Juergen Gross Reported-by: kernel test robot Reviewed-by: Boris Ostrovsky --- arch/x86/xen/enlighten_pv.c | 11 ++- arch/x86/xen/mmu_pv.c | 138 ++++++++++++++---------------------- 2 files changed, 57 insertions(+), 92 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 7d90b3da8bb4..9fec952f84f3 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -347,6 +347,7 @@ static void set_aliased_prot(void *v, pgprot_t prot) unsigned long pfn; struct page *page; unsigned char dummy; + void *av; =20 ptep =3D lookup_address((unsigned long)v, &level); BUG_ON(ptep =3D=3D NULL); @@ -383,14 +384,10 @@ static void set_aliased_prot(void *v, pgprot_t prot) if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0)) BUG(); =20 - if (!PageHighMem(page)) { - void *av =3D __va(PFN_PHYS(pfn)); + av =3D __va(PFN_PHYS(pfn)); =20 - if (av !=3D v) - if (HYPERVISOR_update_va_mapping((unsigned long)av, pte, 0)) - BUG(); - } else - kmap_flush_unused(); + if (av !=3D v && HYPERVISOR_update_va_mapping((unsigned long)av, pte, 0)) + BUG(); =20 preempt_enable(); } diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index 1f9500d0b839..3774fa6d2ef7 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -537,25 +537,26 @@ __visible p4d_t xen_make_p4d(p4dval_t p4d) PV_CALLEE_SAVE_REGS_THUNK(xen_make_p4d); #endif /* CONFIG_PGTABLE_LEVELS >=3D 5 */ =20 -static int xen_pmd_walk(struct mm_struct *mm, pmd_t *pmd, - int (*func)(struct mm_struct *mm, struct page *, enum pt_level), - bool last, unsigned long limit) +static void xen_pmd_walk(struct mm_struct *mm, pmd_t *pmd, + void (*func)(struct mm_struct *mm, struct page *, + enum pt_level), + bool last, unsigned long limit) { - int i, nr, flush =3D 0; + int i, nr; =20 nr =3D last ? pmd_index(limit) + 1 : PTRS_PER_PMD; for (i =3D 0; i < nr; i++) { if (!pmd_none(pmd[i])) - flush |=3D (*func)(mm, pmd_page(pmd[i]), PT_PTE); + (*func)(mm, pmd_page(pmd[i]), PT_PTE); } - return flush; } =20 -static int xen_pud_walk(struct mm_struct *mm, pud_t *pud, - int (*func)(struct mm_struct *mm, struct page *, enum pt_level), - bool last, unsigned long limit) +static void xen_pud_walk(struct mm_struct *mm, pud_t *pud, + void (*func)(struct mm_struct *mm, struct page *, + enum pt_level), + bool last, unsigned long limit) { - int i, nr, flush =3D 0; + int i, nr; =20 nr =3D last ? pud_index(limit) + 1 : PTRS_PER_PUD; for (i =3D 0; i < nr; i++) { @@ -566,29 +567,26 @@ static int xen_pud_walk(struct mm_struct *mm, pud_t *= pud, =20 pmd =3D pmd_offset(&pud[i], 0); if (PTRS_PER_PMD > 1) - flush |=3D (*func)(mm, virt_to_page(pmd), PT_PMD); - flush |=3D xen_pmd_walk(mm, pmd, func, - last && i =3D=3D nr - 1, limit); + (*func)(mm, virt_to_page(pmd), PT_PMD); + xen_pmd_walk(mm, pmd, func, last && i =3D=3D nr - 1, limit); } - return flush; } =20 -static int xen_p4d_walk(struct mm_struct *mm, p4d_t *p4d, - int (*func)(struct mm_struct *mm, struct page *, enum pt_level), - bool last, unsigned long limit) +static void xen_p4d_walk(struct mm_struct *mm, p4d_t *p4d, + void (*func)(struct mm_struct *mm, struct page *, + enum pt_level), + bool last, unsigned long limit) { - int flush =3D 0; pud_t *pud; =20 =20 if (p4d_none(*p4d)) - return flush; + return; =20 pud =3D pud_offset(p4d, 0); if (PTRS_PER_PUD > 1) - flush |=3D (*func)(mm, virt_to_page(pud), PT_PUD); - flush |=3D xen_pud_walk(mm, pud, func, last, limit); - return flush; + (*func)(mm, virt_to_page(pud), PT_PUD); + xen_pud_walk(mm, pud, func, last, limit); } =20 /* @@ -603,12 +601,12 @@ static int xen_p4d_walk(struct mm_struct *mm, p4d_t *= p4d, * We must skip the Xen hole in the middle of the address space, just after * the big x86-64 virtual hole. */ -static int __xen_pgd_walk(struct mm_struct *mm, pgd_t *pgd, - int (*func)(struct mm_struct *mm, struct page *, - enum pt_level), - unsigned long limit) +static void __xen_pgd_walk(struct mm_struct *mm, pgd_t *pgd, + void (*func)(struct mm_struct *mm, struct page *, + enum pt_level), + unsigned long limit) { - int i, nr, flush =3D 0; + int i, nr; unsigned hole_low =3D 0, hole_high =3D 0; =20 /* The limit is the last byte to be touched */ @@ -633,22 +631,20 @@ static int __xen_pgd_walk(struct mm_struct *mm, pgd_t= *pgd, continue; =20 p4d =3D p4d_offset(&pgd[i], 0); - flush |=3D xen_p4d_walk(mm, p4d, func, i =3D=3D nr - 1, limit); + xen_p4d_walk(mm, p4d, func, i =3D=3D nr - 1, limit); } =20 /* Do the top level last, so that the callbacks can use it as a cue to do final things like tlb flushes. */ - flush |=3D (*func)(mm, virt_to_page(pgd), PT_PGD); - - return flush; + (*func)(mm, virt_to_page(pgd), PT_PGD); } =20 -static int xen_pgd_walk(struct mm_struct *mm, - int (*func)(struct mm_struct *mm, struct page *, - enum pt_level), - unsigned long limit) +static void xen_pgd_walk(struct mm_struct *mm, + void (*func)(struct mm_struct *mm, struct page *, + enum pt_level), + unsigned long limit) { - return __xen_pgd_walk(mm, mm->pgd, func, limit); + __xen_pgd_walk(mm, mm->pgd, func, limit); } =20 /* If we're using split pte locks, then take the page's lock and @@ -681,26 +677,17 @@ static void xen_do_pin(unsigned level, unsigned long = pfn) xen_extend_mmuext_op(&op); } =20 -static int xen_pin_page(struct mm_struct *mm, struct page *page, - enum pt_level level) +static void xen_pin_page(struct mm_struct *mm, struct page *page, + enum pt_level level) { unsigned pgfl =3D TestSetPagePinned(page); - int flush; - - if (pgfl) - flush =3D 0; /* already pinned */ - else if (PageHighMem(page)) - /* kmaps need flushing if we found an unpinned - highpage */ - flush =3D 1; - else { + + if (!pgfl) { void *pt =3D lowmem_page_address(page); unsigned long pfn =3D page_to_pfn(page); struct multicall_space mcs =3D __xen_mc_entry(0); spinlock_t *ptl; =20 - flush =3D 0; - /* * We need to hold the pagetable lock between the time * we make the pagetable RO and when we actually pin @@ -737,8 +724,6 @@ static int xen_pin_page(struct mm_struct *mm, struct pa= ge *page, xen_mc_callback(xen_pte_unlock, ptl); } } - - return flush; } =20 /* This is called just after a mm has been created, but it has not @@ -752,14 +737,7 @@ static void __xen_pgd_pin(struct mm_struct *mm, pgd_t = *pgd) =20 xen_mc_batch(); =20 - if (__xen_pgd_walk(mm, pgd, xen_pin_page, USER_LIMIT)) { - /* re-enable interrupts for flushing */ - xen_mc_issue(0); - - kmap_flush_unused(); - - xen_mc_batch(); - } + __xen_pgd_walk(mm, pgd, xen_pin_page, USER_LIMIT); =20 xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa(pgd))); =20 @@ -803,11 +781,10 @@ void xen_mm_pin_all(void) spin_unlock(&pgd_lock); } =20 -static int __init xen_mark_pinned(struct mm_struct *mm, struct page *page, - enum pt_level level) +static void __init xen_mark_pinned(struct mm_struct *mm, struct page *page, + enum pt_level level) { SetPagePinned(page); - return 0; } =20 /* @@ -823,12 +800,12 @@ static void __init xen_after_bootmem(void) xen_pgd_walk(&init_mm, xen_mark_pinned, FIXADDR_TOP); } =20 -static int xen_unpin_page(struct mm_struct *mm, struct page *page, - enum pt_level level) +static void xen_unpin_page(struct mm_struct *mm, struct page *page, + enum pt_level level) { unsigned pgfl =3D TestClearPagePinned(page); =20 - if (pgfl && !PageHighMem(page)) { + if (pgfl) { void *pt =3D lowmem_page_address(page); unsigned long pfn =3D page_to_pfn(page); spinlock_t *ptl =3D NULL; @@ -859,8 +836,6 @@ static int xen_unpin_page(struct mm_struct *mm, struct = page *page, xen_mc_callback(xen_pte_unlock, ptl); } } - - return 0; /* never need to flush on unpin */ } =20 /* Release a pagetables pages back as normal RW */ @@ -1554,20 +1529,14 @@ static inline void xen_alloc_ptpage(struct mm_struc= t *mm, unsigned long pfn, if (static_branch_likely(&xen_struct_pages_ready)) SetPagePinned(page); =20 - if (!PageHighMem(page)) { - xen_mc_batch(); + xen_mc_batch(); =20 - __set_pfn_prot(pfn, PAGE_KERNEL_RO); + __set_pfn_prot(pfn, PAGE_KERNEL_RO); =20 - if (level =3D=3D PT_PTE && USE_SPLIT_PTE_PTLOCKS) - __pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn); + if (level =3D=3D PT_PTE && USE_SPLIT_PTE_PTLOCKS) + __pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn); =20 - xen_mc_issue(PARAVIRT_LAZY_MMU); - } else { - /* make sure there are no stray mappings of - this page */ - kmap_flush_unused(); - } + xen_mc_issue(PARAVIRT_LAZY_MMU); } } =20 @@ -1590,16 +1559,15 @@ static inline void xen_release_ptpage(unsigned long= pfn, unsigned level) trace_xen_mmu_release_ptpage(pfn, level, pinned); =20 if (pinned) { - if (!PageHighMem(page)) { - xen_mc_batch(); + xen_mc_batch(); =20 - if (level =3D=3D PT_PTE && USE_SPLIT_PTE_PTLOCKS) - __pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, pfn); + if (level =3D=3D PT_PTE && USE_SPLIT_PTE_PTLOCKS) + __pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, pfn); =20 - __set_pfn_prot(pfn, PAGE_KERNEL); + __set_pfn_prot(pfn, PAGE_KERNEL); + + xen_mc_issue(PARAVIRT_LAZY_MMU); =20 - xen_mc_issue(PARAVIRT_LAZY_MMU); - } ClearPagePinned(page); } } --=20 2.26.2