From nobody Thu May 2 08:12:11 2024 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; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1673536922; cv=none; d=zohomail.com; s=zohoarc; b=bwwrSuIB/ddg7PcedKE0Gbx5/wSo3tAMvUjRVtwWMkXUIs+EmHSQ8GtlJKQcvTf5mKThSB14d1H7W5Zy8wNAoxl6satet/1iuy//F7An7x2VFGTqVOBF6Hk/e6wscyWzViPFTqQCQeHftoKQUdauc+JrOLwlGiS808/53oO2INc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673536922; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=2n0IdQPvR+Gxy3g7DvPKITwTHiT/5QBMjcXvwvG5gq8=; b=i8P5MobwX2rFgZq3uN2zRZVioaPQbmSNfh+htW+CrDW9xF2uKr/4/6QyaCsoNgCtcatXvGQGGM8FejMU7Z9XgYHcdxnDXZ1zt3GL7Zal+WWFiPdQYGqyiisPbml9QYPlKXySM1HcqtPtRhc0iyDnEu1yMEq3kWKtZi1HSLquMI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1673536922166608.1121965524362; Thu, 12 Jan 2023 07:22:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.476283.738377 (Exim 4.92) (envelope-from ) id 1pFzOb-0005E9-IL; Thu, 12 Jan 2023 15:21:37 +0000 Received: by outflank-mailman (output) from mailman id 476283.738377; Thu, 12 Jan 2023 15:21:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pFzOb-0005E2-Fe; Thu, 12 Jan 2023 15:21:37 +0000 Received: by outflank-mailman (input) for mailman id 476283; Thu, 12 Jan 2023 15:21:36 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pFzOa-0005Dv-4b for xen-devel@lists.xenproject.org; Thu, 12 Jan 2023 15:21:36 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ccad159d-928c-11ed-91b6-6bf2151ebd3b; Thu, 12 Jan 2023 16:21:34 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4D54D40269; Thu, 12 Jan 2023 15:21:34 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E045513776; Thu, 12 Jan 2023 15:21:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1KxjNX0lwGM6IwAAMHmgww (envelope-from ); Thu, 12 Jan 2023 15:21:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ccad159d-928c-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1673536894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2n0IdQPvR+Gxy3g7DvPKITwTHiT/5QBMjcXvwvG5gq8=; b=aBmyfXqLewedueE1l8HgnS8oOWeLEQsBebQ3+JmtzpZzl9WKiSECnoSe2djtAFYUFg2yN/ acxUR6stqti7Qe76GIxbS5WMojGnRTf19LbpN8XK+a9njRm4QPpWpJ8Z+aGoVqnwra2MEk bbQFMgCf9WV/aQ3RDAqPmCnv9Vf1osI= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux-foundation.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "Srivatsa S. Bhat (VMware)" , Alexey Makhalov , VMware PV-Drivers Reviewers , Boris Ostrovsky , xen-devel@lists.xenproject.org Subject: [PATCH] x86/paravirt: merge activate_mm and dup_mmap callbacks Date: Thu, 12 Jan 2023 16:21:32 +0100 Message-Id: <20230112152132.4399-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1673536924240100001 Content-Type: text/plain; charset="utf-8" The two paravirt callbacks .mmu.activate_mm and .mmu.dup_mmap are sharing the same implementations in all cases: for Xen PV guests they are pinning the PGD of the new mm_struct, and for all other cases they are a NOP. So merge them to a common callback .mmu.enter_mmap (in contrast to the corresponding already existing .mmu.exit_mmap). As the first parameter of the old callbacks isn't used, drop it from the replacement one. Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky --- arch/x86/include/asm/mmu_context.h | 4 ++-- arch/x86/include/asm/paravirt.h | 14 +++----------- arch/x86/include/asm/paravirt_types.h | 7 ++----- arch/x86/kernel/paravirt.c | 3 +-- arch/x86/xen/mmu_pv.c | 12 ++---------- 5 files changed, 10 insertions(+), 30 deletions(-) diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_= context.h index b8d40ddeab00..6a14b6c2165c 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -134,7 +134,7 @@ extern void switch_mm_irqs_off(struct mm_struct *prev, = struct mm_struct *next, =20 #define activate_mm(prev, next) \ do { \ - paravirt_activate_mm((prev), (next)); \ + paravirt_enter_mmap(next); \ switch_mm((prev), (next), NULL); \ } while (0); =20 @@ -167,7 +167,7 @@ static inline void arch_dup_pkeys(struct mm_struct *old= mm, static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct = *mm) { arch_dup_pkeys(oldmm, mm); - paravirt_arch_dup_mmap(oldmm, mm); + paravirt_enter_mmap(mm); return ldt_dup_context(oldmm, mm); } =20 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravir= t.h index 73e9522db7c1..07bbdceaf35a 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -332,16 +332,9 @@ static inline void tss_update_io_bitmap(void) } #endif =20 -static inline void paravirt_activate_mm(struct mm_struct *prev, - struct mm_struct *next) +static inline void paravirt_enter_mmap(struct mm_struct *next) { - PVOP_VCALL2(mmu.activate_mm, prev, next); -} - -static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm, - struct mm_struct *mm) -{ - PVOP_VCALL2(mmu.dup_mmap, oldmm, mm); + PVOP_VCALL1(mmu.enter_mmap, next); } =20 static inline int paravirt_pgd_alloc(struct mm_struct *mm) @@ -787,8 +780,7 @@ extern void default_banner(void); =20 #ifndef __ASSEMBLY__ #ifndef CONFIG_PARAVIRT_XXL -static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm, - struct mm_struct *mm) +static inline void paravirt_enter_mmap(struct mm_struct *mm) { } #endif diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/p= aravirt_types.h index 8c1da419260f..71bf64b963df 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -164,11 +164,8 @@ struct pv_mmu_ops { unsigned long (*read_cr3)(void); void (*write_cr3)(unsigned long); =20 - /* Hooks for intercepting the creation/use of an mm_struct. */ - void (*activate_mm)(struct mm_struct *prev, - struct mm_struct *next); - void (*dup_mmap)(struct mm_struct *oldmm, - struct mm_struct *mm); + /* Hook for intercepting the creation/use of an mm_struct. */ + void (*enter_mmap)(struct mm_struct *mm); =20 /* Hooks for allocating and freeing a pagetable top-level */ int (*pgd_alloc)(struct mm_struct *mm); diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 327757afb027..ff1109b9c6cd 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -352,8 +352,7 @@ struct paravirt_patch_template pv_ops =3D { .mmu.make_pte =3D PTE_IDENT, .mmu.make_pgd =3D PTE_IDENT, =20 - .mmu.dup_mmap =3D paravirt_nop, - .mmu.activate_mm =3D paravirt_nop, + .mmu.enter_mmap =3D paravirt_nop, =20 .mmu.lazy_mode =3D { .enter =3D paravirt_nop, diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index ee29fb558f2e..b3b8d289b9ab 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -885,14 +885,7 @@ void xen_mm_unpin_all(void) spin_unlock(&pgd_lock); } =20 -static void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next) -{ - spin_lock(&next->page_table_lock); - xen_pgd_pin(next); - spin_unlock(&next->page_table_lock); -} - -static void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) +static void xen_enter_mmap(struct mm_struct *mm) { spin_lock(&mm->page_table_lock); xen_pgd_pin(mm); @@ -2153,8 +2146,7 @@ static const typeof(pv_ops) xen_mmu_ops __initconst = =3D { .make_p4d =3D PV_CALLEE_SAVE(xen_make_p4d), #endif =20 - .activate_mm =3D xen_activate_mm, - .dup_mmap =3D xen_dup_mmap, + .enter_mmap =3D xen_enter_mmap, .exit_mmap =3D xen_exit_mmap, =20 .lazy_mode =3D { --=20 2.35.3