From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D523C405C3C for ; Tue, 26 May 2026 15:08:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779808099; cv=none; b=saw+UWYeupe4iAyJtKKe/LNsj4ClDr7FtKIzYnNSXHN2DL7sHnwePhmI+a9xXwrbn1zsaGvTMBGPlhHuzQPYPFodeD5dmoxiklcvH0My6Gl665kjtJPHnqHw+3AlWJTelQdVHvYsZnUk3Mc33NU7Ldy10hzs15VYmNYgxYPOYNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779808099; c=relaxed/simple; bh=ho7LSJUIaRicbRiESjzT0e8lCzjdCm7HrOGZIc8WEok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Us1DQhf2xZarSASnY4otVq8MiMaY3bWKtN6wIl1qlRcRAqm2YxM31IMhQqe6pEJWyqqQ2AYCRqY2xxOF5jFk/k19HFwS1a9T9Iri8gZ9Bjt8lmvyVseeqYJL2ASzpY1wL1g+nMrhffYaI1+iJX5z2dnCmS68pyWPNP5/VmarVjY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=PFA/dfob; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=PFA/dfob; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="PFA/dfob"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="PFA/dfob" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B5B4075EA1; Tue, 26 May 2026 15:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808092; 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: in-reply-to:in-reply-to:references:references; bh=htKnackiGTLT6ra2yiyVCBoM5uojYzGpE60av2lvlE4=; b=PFA/dfob5jaYx8ziU/VgRy6SDe4zshqEhaFAiCgmyGJnLa9BG79cjVXHb65SY6s2PpEOb6 ZelH9pCmaDauo7y1BTg/Wh4jQRtBNhSDp8kzKI+gHROm+cpqhCaDqubzp97my98RgEFJfP QRRvI7r+TZvT/QvfBIZsUjLJE/Ufimk= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808092; 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: in-reply-to:in-reply-to:references:references; bh=htKnackiGTLT6ra2yiyVCBoM5uojYzGpE60av2lvlE4=; b=PFA/dfob5jaYx8ziU/VgRy6SDe4zshqEhaFAiCgmyGJnLa9BG79cjVXHb65SY6s2PpEOb6 ZelH9pCmaDauo7y1BTg/Wh4jQRtBNhSDp8kzKI+gHROm+cpqhCaDqubzp97my98RgEFJfP QRRvI7r+TZvT/QvfBIZsUjLJE/Ufimk= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7AECC5A280; Tue, 26 May 2026 15:08:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id xZX0HFy3FWqaVQAAD6G6ig (envelope-from ); Tue, 26 May 2026 15:08:12 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , xen-devel@lists.xenproject.org Subject: [PATCH 2/5] x86/xen: Change interface of xen_mc_issue() Date: Tue, 26 May 2026 17:05:11 +0200 Message-ID: <20260526150514.129330-3-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150514.129330-1-jgross@suse.com> References: <20260526150514.129330-1-jgross@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spam-Score: -2.79 X-Spam-Flag: NO X-Spamd-Result: default: False [-2.79 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.19)[-0.968]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[10]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; URIBL_BLOCKED(0.00)[suse.com:email,suse.com:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] Today xen_mc_issue() is deciding whether to call xen_mc_flush() or not based on the lazy mode input parameter passed. Modify this interface to pass a boolean indicating whether the flush should be done. For querying lazy mmu mode use the is_lazy_mmu_mode_active() helper. This is done in preparation for dropping the xen_lazy_mode percpu variable. Signed-off-by: Juergen Gross --- arch/x86/xen/enlighten_pv.c | 8 ++++---- arch/x86/xen/mmu_pv.c | 38 ++++++++++++++++++------------------- arch/x86/xen/xen-ops.h | 3 +-- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index ed2d7a3756ce..428189f5d437 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -544,7 +544,7 @@ static void xen_set_ldt(const void *addr, unsigned entries) MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); } static void xen_load_gdt(const struct desc_ptr *dtr) @@ -649,7 +649,7 @@ static void xen_load_tls(struct thread_struct *t, unsigned int cpu) load_TLS_descriptor(t, cpu, 1); load_TLS_descriptor(t, cpu, 2); - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); } static void xen_load_gs_index(unsigned int idx) @@ -1011,7 +1011,7 @@ static void xen_load_sp0(unsigned long sp0) mcs = xen_mc_entry(0); MULTI_stack_switch(mcs.mc, __KERNEL_DS, sp0); - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); this_cpu_write(cpu_tss_rw.x86_tss.sp0, sp0); } @@ -1071,7 +1071,7 @@ static void xen_write_cr0(unsigned long cr0) MULTI_fpu_taskswitch(mcs.mc, (cr0 & X86_CR0_TS) != 0); - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); } static void xen_write_cr4(unsigned long cr4) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index cd80406be9c6..51dbdc67c73c 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -290,7 +290,7 @@ static void xen_set_pmd_hyper(pmd_t *ptr, pmd_t val) u.val = pmd_val_ma(val); xen_extend_mmu_update(&u); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); preempt_enable(); } @@ -333,7 +333,7 @@ static bool xen_batched_set_pte(pte_t *ptep, pte_t pteval) u.val = pte_val_ma(pteval); xen_extend_mmu_update(&u); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); return true; } @@ -380,7 +380,7 @@ static void xen_ptep_modify_prot_commit(struct vm_area_struct *vma, u.val = pte_val_ma(pte); xen_extend_mmu_update(&u); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); } /* Assume pteval_t is equivalent to all the other *val_t types. */ @@ -474,7 +474,7 @@ static void xen_set_pud_hyper(pud_t *ptr, pud_t val) u.val = pud_val_ma(val); xen_extend_mmu_update(&u); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); preempt_enable(); } @@ -557,7 +557,7 @@ static void __init xen_set_p4d_hyper(p4d_t *ptr, p4d_t val) __xen_set_p4d_hyper(ptr, val); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); preempt_enable(); } @@ -589,7 +589,7 @@ static void xen_set_p4d(p4d_t *ptr, p4d_t val) if (user_ptr) __xen_set_p4d_hyper((p4d_t *)user_ptr, val); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); } __visible p4dval_t xen_p4d_val(p4d_t p4d) @@ -816,7 +816,7 @@ static void __xen_pgd_pin(struct mm_struct *mm, pgd_t *pgd) PFN_DOWN(__pa(user_pgd))); } - xen_mc_issue(0); + xen_mc_issue(true); } static void xen_pgd_pin(struct mm_struct *mm) @@ -933,7 +933,7 @@ static void __xen_pgd_unpin(struct mm_struct *mm, pgd_t *pgd) __xen_pgd_walk(mm, pgd, xen_unpin_page, USER_LIMIT); - xen_mc_issue(0); + xen_mc_issue(true); } static void xen_pgd_unpin(struct mm_struct *mm) @@ -1309,7 +1309,7 @@ static noinline void xen_flush_tlb(void) op->cmd = MMUEXT_TLB_FLUSH_LOCAL; MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); preempt_enable(); } @@ -1329,7 +1329,7 @@ static void xen_flush_tlb_one_user(unsigned long addr) op->arg1.linear_addr = addr & PAGE_MASK; MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); preempt_enable(); } @@ -1366,7 +1366,7 @@ static void xen_flush_tlb_multi(const struct cpumask *cpus, MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); } static unsigned long xen_read_cr3(void) @@ -1425,7 +1425,7 @@ static void xen_write_cr3(unsigned long cr3) else __xen_write_cr3(false, 0); - xen_mc_issue(XEN_LAZY_CPU); /* interrupts restored */ + xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); /* interrupts restored */ } /* @@ -1460,7 +1460,7 @@ static void __init xen_write_cr3_init(unsigned long cr3) __xen_write_cr3(true, cr3); - xen_mc_issue(XEN_LAZY_CPU); /* interrupts restored */ + xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); /* interrupts restored */ } static int xen_pgd_alloc(struct mm_struct *mm) @@ -1622,7 +1622,7 @@ static inline void xen_alloc_ptpage(struct mm_struct *mm, unsigned long pfn, !pinned) __pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); } } @@ -1652,7 +1652,7 @@ static inline void xen_release_ptpage(unsigned long pfn, unsigned level) __set_pfn_prot(pfn, PAGE_KERNEL); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); ClearPagePinned(page); } @@ -1875,7 +1875,7 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn) */ xen_mc_batch(); __xen_write_cr3(true, __pa(init_top_pgt)); - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() != XEN_LAZY_CPU); /* We can't that easily rip out L3 and L2, as the Xen pagetables are * set out this way: [L4], [L1], [L2], [L3], [L1], [L1] ... for @@ -2266,7 +2266,7 @@ static void xen_zap_pfn_range(unsigned long vaddr, unsigned int order, if (out_frames) out_frames[i] = virt_to_pfn((void *)vaddr); } - xen_mc_issue(0); + xen_mc_issue(true); } /* @@ -2309,7 +2309,7 @@ static void xen_remap_exchanged_ptes(unsigned long vaddr, int order, set_phys_to_machine(virt_to_pfn((void *)vaddr), mfn); } - xen_mc_issue(0); + xen_mc_issue(true); } /* @@ -2450,7 +2450,7 @@ static noinline void xen_flush_tlb_all(void) op->cmd = MMUEXT_TLB_FLUSH_ALL; MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); preempt_enable(); } diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index dc892f421f25..dc265bdda24d 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -112,9 +112,8 @@ static inline struct multicall_space xen_mc_entry(size_t args) void xen_mc_flush(void); /* Issue a multicall if we're not in a lazy mode */ -static inline void xen_mc_issue(unsigned mode) +static inline void xen_mc_issue(bool flush) { - bool flush = !(xen_get_lazy_mode() & mode); unsigned long flags = this_cpu_read(xen_mc_irq_flags); trace_xen_mc_issue(flush, flags); -- 2.54.0