From patchwork Wed Apr 19 10:45:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13216632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62D43C6FD18 for ; Wed, 19 Apr 2023 10:46:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.523327.813279 (Exim 4.92) (envelope-from ) id 1pp5K6-0006DH-AC; Wed, 19 Apr 2023 10:46:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 523327.813279; Wed, 19 Apr 2023 10:46:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pp5K6-0006DA-7A; Wed, 19 Apr 2023 10:46:02 +0000 Received: by outflank-mailman (input) for mailman id 523327; Wed, 19 Apr 2023 10:46:00 +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 1pp5K4-0006CV-KF for xen-devel@lists.xenproject.org; Wed, 19 Apr 2023 10:46:00 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0621.outbound.protection.outlook.com [2a01:111:f400:fe0c::621]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5f2ec1c3-de9f-11ed-b21f-6b7b168915f2; Wed, 19 Apr 2023 12:46:00 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AM7PR04MB7013.eurprd04.prod.outlook.com (2603:10a6:20b:116::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Wed, 19 Apr 2023 10:45:58 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::52b2:f58:e19:56ae]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::52b2:f58:e19:56ae%2]) with mapi id 15.20.6298.045; Wed, 19 Apr 2023 10:45:58 +0000 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: 5f2ec1c3-de9f-11ed-b21f-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K125paLkDc1s2CPG5UUnfiMudzOIk6DAsR9/8y6vXMWj4SrmpQruwSVisRexo6Rlfpqoi2ftM0VcPgw8e0c5EhYe27UmlbSYuUpJgVlH1ymuORoN5WCgBA07W/3GWaQtoMlRcLTYobMnDIQUYtG+le5er0AVaJQvXBiwO3MlesnjnyUKSELZPeWGCTITiAKuyKbklQHA7LWByIjDxuWnh2/Y+InEOYFwQGGCjPa0tFVmPv1kVocBXqlprLOh4aa9OB38sEqK8XWhtkWiclX4xRhLPHmhe9vjl/5CNYNSYAf0XjH11XGd48w2S8L7GgBnZfuM9GeLF1UrarqxGOfFLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AgoBtbMdStYg/E8daXMr1Bc+OTEzf/aiDaWtJfzyYEE=; b=cFWQUhPUAgwQh80aKGonFr6PpoQ+BcYVAeZT4kRUh1Zkg7m7M9pglpmrRqEwjLk9i8SzsVMtNgr+2w/qJhVySCMeVY8LrBqroKs/JKMKnvXfLcRWur8AavgbMJ6xtgJQJHtARiBeiITF34203/5cr0/ucpT95gO61GSK/i634uJCt+gEhlwC1s7KxFffGX8kMF0cWwKb4xJkC1UWJlqozQhPFfhW4qqdBB6yG5ke6q096W0+fyRoGlz/4mePbL+yTuhD1yai9w3BdteGSoe/+6OgmyKhSz6HdAEZ2ksfr6Vd3jP9l+I4yJLDOCmgAH4yj15uW9PXqW1ZnDmpXAFQzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AgoBtbMdStYg/E8daXMr1Bc+OTEzf/aiDaWtJfzyYEE=; b=HfOc5E/a53WNqQkgSMWRVmuEMPw06FcsuRGCRyG3p7QKZ/+Jjd95OZqI/nU/n9AhWJPV/aUhIOMF3emA3OlMjuXS1DXISVMh6sIaucMMcRZC43LukVhbq02BVx3ccTWEELPDTjL36b82/udoXpj8dLSEhMuvZRKZRh/orrn7ol00us22eTUdB6IHyka7S0uGKFnev1M2YDO6ntXmTrvcVa72YspODTpa5aTflSkqga+R0Ar2Z6RXXHIU5yF0hj7sY3Ax1VsZkMs1SIFCAAHVbc6iGdLu2QUA6kDd5c8i2XkbLS1W8/JtQ/lOWhNch4C765OqLQFj6a9XRNY33idFyA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <0e60520c-d660-1a83-3f57-3466a0ad617b@suse.com> Date: Wed, 19 Apr 2023 12:45:57 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 3/5] x86/PV: restrict guest-induced WBINVD (or alike) to cache writeback Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: <4b42e920-f007-186c-d838-a0294bfa86b5@suse.com> In-Reply-To: <4b42e920-f007-186c-d838-a0294bfa86b5@suse.com> X-ClientProxiedBy: FR2P281CA0126.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9d::20) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AM7PR04MB7013:EE_ X-MS-Office365-Filtering-Correlation-Id: 42850444-faec-4451-0e09-08db40c3428a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mlAYDtB9+UlHT5sxw06Ju+CZj7eD0ICRjgu9Z4vP1bvZQcfedeQ3LRZ69/XD5T9bp6IGB66vxcuxXA8MgEu/wKReVSkGBu1nOgB3YNfXeuKgI5wvfKcSV/RcZy30bKkFTr4pjS2a2NJ6L4hzKlm7v/UNkmO7qxuukUpbzQZdxIphGPYL5RTWnUxu4CqR7WDbqWi9V3gVdFxdsqdNbm8GBFOYDo+tAc2esESg2l2+rjetyksNNHbHIeAv9bibtGxXI1bMMmMcYHfdE50FFG3NOHpJwaho0hYoQcUwqvKKVO85Ra57gl/RtIGCZv+hQ3IyxBgPntLM69oVupQsU3eK47SUI1GpkTFbBMlXsVyZOCO1dRpcyx0BO8yEmB92FBBEm//Rqeq2xg3cRZp+62wLuYQNSDEbt8mqGoFMVd7upirhpzOtxldSrcwF6dm3zpHGtPOzTxC+Nxp0IGHP07pgXgm2qWp4s9QsvKotENsSDdBnC8VeHzUhPJghXw1JiZJgM+ULKtE2etOrxHsN+qlggIpwSRDpghoqnDjmF/e1txT7swaRdzXQYU0wHLQFDhRGtUN+yEiwM4XSPcIGF/MQJ3ivp6MqtLwonW1+3/6werlfyxnMYceLbBtNWC2epnKLIOVDRo2amZ0QbWztnhC0KA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(39850400004)(396003)(346002)(376002)(366004)(451199021)(5660300002)(86362001)(2616005)(83380400001)(31696002)(6512007)(186003)(6506007)(26005)(38100700002)(8676002)(8936002)(54906003)(478600001)(6486002)(316002)(41300700001)(36756003)(4326008)(6916009)(66946007)(66556008)(31686004)(66476007)(2906002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?T9lvQlA4OCGvL0d/bBD+aQhtkIcc?= =?utf-8?q?h95DXbEl1krpYCO/1D1gfs8nrKanuaGvAaenZJkrIzoStb5nI0sdZ6q7XbL1NBpY1?= =?utf-8?q?/YlmSHtDHihQ/LYloPupCgJmAL8dKNPRprc7QZj12Qv4Kz6W9dWrRx/xr6BZVZAKJ?= =?utf-8?q?yHX6JGfZULLo2hOWD/FuVA5SoSjQ2hmPOIDnaqTDx760y2XSL9t/LmL0PaxGdJz6Z?= =?utf-8?q?u5aKXQAoqn2sDAhod2G2kkIj8W7+rTIQBMJ9a4XjD5aw+DQXqM2AnfL+YpchUV3Dm?= =?utf-8?q?1pGkTQ0anp0Lt/fmlQDv8QpjpgW2H9N5eccAPTZjiGEu6n8U3bLtJXm0WBCeUoyHe?= =?utf-8?q?Ek//j55yquqV2bOWnrU1Wil2XXZMMZ/8dM7Ok/7La9HBVQQxD119kOLJHiNB4pQQD?= =?utf-8?q?UC0GhbK+xwRZYZuQS4TLX3diJk6zv8Cry8d5WGULAVSaLgWDxwqCxZ8zU6660AsR3?= =?utf-8?q?HRRnXDymfO17Oqqyu+VN7VV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N9scb3JJAVcNvUR0LGc6SFVfiM2L8+uQcKG6YL1DejAjtcp3?= =?utf-8?q?KTmLD4i70ldYnmgLY2riLZGG8/1pi91PY8aoX8vSN8sggzsDBti6jqMUK2z/yszWl?= =?utf-8?q?seDHbRTqq6odPZGbHsQR9kEFCAMznC7l0ofRinKxj13DxJ0rWQktlxKS/aiDK5pKQ?= =?utf-8?q?UZtthSOp8CCP?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42850444-faec-4451-0e09-08db40c3428a X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2023 10:45:58.3667 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iNvkjVHBMHpDudxfPFXpZAdYoLCYQK3QRGnGWg/QY0szfAO0j1Zh5Nch+1tZgUMVV+ryjclHgQl+xTY6pKZxrw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7013 We allow its use for writeback purposes only anyway, so let's also carry these out that way on capable hardware. We can then also expose the WBNOINVD feature, as there's no difference to WBINVD anymore. Note that respective emulation logic has already been in place since ad3abc47dd23 ("x86emul: support WBNOINVD"). Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3772,7 +3772,7 @@ long do_mmuext_op( else if ( unlikely(!cache_flush_permitted(currd)) ) rc = -EACCES; else - wbinvd(); + wbnoinvd(); break; case MMUEXT_FLUSH_CACHE_GLOBAL: @@ -3788,7 +3788,7 @@ long do_mmuext_op( if ( !cpumask_intersects(mask, per_cpu(cpu_sibling_mask, cpu)) ) __cpumask_set_cpu(cpu, mask); - flush_mask(mask, FLUSH_CACHE); + flush_mask(mask, FLUSH_WRITEBACK); } else rc = -EINVAL; --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -1196,10 +1196,8 @@ static int cf_check cache_op( * newer linux uses this in some start-of-day timing loops. */ ; - else if ( op == x86emul_wbnoinvd /* && cpu_has_wbnoinvd */ ) - wbnoinvd(); else - wbinvd(); + wbnoinvd(); return X86EMUL_OKAY; } --- a/xen/include/public/arch-x86/cpufeatureset.h +++ b/xen/include/public/arch-x86/cpufeatureset.h @@ -238,7 +238,7 @@ XEN_CPUFEATURE(EFRO, 7*32+10) / /* AMD-defined CPU features, CPUID level 0x80000008.ebx, word 8 */ XEN_CPUFEATURE(CLZERO, 8*32+ 0) /*A CLZERO instruction */ XEN_CPUFEATURE(RSTR_FP_ERR_PTRS, 8*32+ 2) /*A (F)X{SAVE,RSTOR} always saves/restores FPU Error pointers */ -XEN_CPUFEATURE(WBNOINVD, 8*32+ 9) /*S WBNOINVD instruction */ +XEN_CPUFEATURE(WBNOINVD, 8*32+ 9) /*A WBNOINVD instruction */ XEN_CPUFEATURE(IBPB, 8*32+12) /*A IBPB support only (no IBRS, used by AMD) */ XEN_CPUFEATURE(IBRS, 8*32+14) /*S MSR_SPEC_CTRL.IBRS */ XEN_CPUFEATURE(AMD_STIBP, 8*32+15) /*S MSR_SPEC_CTRL.STIBP */