From nobody Tue Feb 10 05:48:34 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; 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1746520513; cv=none; d=zohomail.com; s=zohoarc; b=FsLr4AY6vQ6quXynahliOhOlaq1KYm8oZrrBhfFtN9ThA88MHY6uco/cKyjX9ngZdWmvyRab+GyRIc70/6nM4XxHEydFFgGR+2LjddB9ooBjcyb/gaxVqE91ZCaIr0r4oFpJMFgXg1G4VnseIeW0T2Ibts9PR820BkjZEC5rUsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746520513; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=st45ZJ9i+zKbNGPJ/gNiCriyCwXBLOobUVRy9hZSFAA=; b=QmINxmhMln088VQHorRLIP5H/o1IxFzYqM7qh649iWHa/LmipafHdfvub/jhMrZ+gHafStfSjyZjZ6jbHOuURZ6FivhRPVk7yK1KfYrPGd6I9Es2we5sUNkhDXJv1HVeffeQBnbR9Yz8j1zvjPVZtiwm1jK4Uzua/DxR0c4oZdI= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1746520513174134.10132957394285; Tue, 6 May 2025 01:35:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.976747.1363893 (Exim 4.92) (envelope-from ) id 1uCDlK-0004Fr-5Y; Tue, 06 May 2025 08:34:50 +0000 Received: by outflank-mailman (output) from mailman id 976747.1363893; Tue, 06 May 2025 08:34:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uCDlK-0004Fk-2J; Tue, 06 May 2025 08:34:50 +0000 Received: by outflank-mailman (input) for mailman id 976747; Tue, 06 May 2025 08:34:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uCDlI-00041m-5G for xen-devel@lists.xenproject.org; Tue, 06 May 2025 08:34:48 +0000 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [2a00:1450:4864:20::42b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f7235d67-2a54-11f0-9ffb-bf95429c2676; Tue, 06 May 2025 10:34:46 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-39141ffa9fcso5709969f8f.0 for ; Tue, 06 May 2025 01:34:46 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a099ae7cc6sm13132515f8f.55.2025.05.06.01.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 May 2025 01:34:45 -0700 (PDT) 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: f7235d67-2a54-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1746520485; x=1747125285; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=st45ZJ9i+zKbNGPJ/gNiCriyCwXBLOobUVRy9hZSFAA=; b=a8ZLtsKkNfiDnWk9AHFIHBY98W9ixl0Z71swNHBGKXOBG4GnMUYVx+fLGP3tAj86yi gFECgZUXWV7kXkO1EYoqAmUnS2Pw3l3SrO6IC8i19OfpTCnNkHRR6KC61Nux3dIEgFA1 Ee67in+25XPxQxgJ0q72BsyPcRlv/1YUW7hIU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746520485; x=1747125285; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=st45ZJ9i+zKbNGPJ/gNiCriyCwXBLOobUVRy9hZSFAA=; b=dGq9O4wPMzAzOemq3HKZTGbxnON8dWdtVTcNcuBf35KCyHL9s7R+HDkB0rnrfBQ+xx nejsUq5XU028k5o7yOC6UftlsCvjm3BCObobu9fpdeNbNRQ01pco+l0M/0MBj6oZ0a8E 7yF7KSRm5DZcp6QLgB6a0V4/JTiwGIu9s3WqQwOG/OkmnUSj2vh2f9frCD4T/mbudqAu kemmO83jfrhjzF7mriEMOzLgOViOoOBNIlWDPw5XmBTakoU0LJXtu2BfBHZvVW3XKjkS xKVDb0W6ZXsuU3tC1CjvnKIKENG45yTasbmeTA2oQvINoju8CCusfMephHV7q8HHCgPg 0Jpg== X-Gm-Message-State: AOJu0YxeXIN8X/ohwUUdYv4vqJJLKULTN9079qH2/H1YI+7oP88qZO+u xPtl6zWNkOaAFFOH9f5KyNbfyXEUQzzGFcG0U7RN5svUy23PqHhfhvYVnDHYYccuaOQWVuGdkDh R X-Gm-Gg: ASbGnct+zEM8EBXwl6ldZJaGujUoVjrfoK3L13LAwsl5ScUpRnIxri9+0wtNPaqZEh4 37xCXPtfL5r927DO3Z4b/o1GhpMR5NflsZLcQQkm+IpvVMVa8gJPnw0SIafd54b4wWG0Gtxq7HI g3D5Y313vm04PI+tXFMzXwhN4HlQBqewOcQUIr0fHPycnz/m1M8ROftyUmNBYjQIsKd3iHho5Qk 4pUUffYDRmGqz9i5aEUFs6RzDjryR/PK/nKWpQv7uxp9wOs7GsCxDifabRt3UtYGeixYvoLpeA1 KITHmpNvSAfoXZ40bRaGzkVzO23TxXzxFFk11LTX89IZIA== X-Google-Smtp-Source: AGHT+IHVj/uKcBnWhZL2WS4VG4BiWU+QA7k/IU9uSQePRA0qdu0xcCV8sfNEBXnjmr16UVzoeHKt1g== X-Received: by 2002:a05:6000:4383:b0:39c:f0d:9146 with SMTP id ffacd0b85a97d-3a0ac1ff746mr1264138f8f.45.1746520485296; Tue, 06 May 2025 01:34:45 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH 1/9] x86/pv: fix MMUEXT_FLUSH_CACHE to flush all pCPU caches Date: Tue, 6 May 2025 10:31:40 +0200 Message-ID: <20250506083148.34963-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250506083148.34963-1-roger.pau@citrix.com> References: <20250506083148.34963-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1746520514828116600 The implementation of MMUEXT_FLUSH_CACHE is bogus, as it doesn't account to flush the cache of any previous pCPU where the current vCPU might have run, and hence is likely to not work as expected. Fix this by resorting to use the same logic as MMUEXT_FLUSH_CACHE_GLOBAL, which will be correct in all cases. Fixes: 534ffcb416bb ("Fix WBINVD by adding a new hypercall.") Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich --- Alternatively, the hypercall could be made correct by keeping track of the pCPUs the vCPU has run on since the last cache flush. That's however more work. See later in the series. --- xen/arch/x86/mm.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 66c15a3c864f..38e214352201 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3805,14 +3805,11 @@ long do_mmuext_op( break; =20 case MMUEXT_FLUSH_CACHE: - if ( unlikely(currd !=3D pg_owner) ) - rc =3D -EPERM; - else if ( unlikely(!cache_flush_permitted(currd)) ) - rc =3D -EACCES; - else - wbinvd(); - break; - + /* + * Dirty pCPU caches where the current vCPU has been scheduled= are + * not tracked, and hence we need to resort to a global cache + * flush for correctness. + */ case MMUEXT_FLUSH_CACHE_GLOBAL: if ( unlikely(currd !=3D pg_owner) ) rc =3D -EPERM; --=20 2.48.1