From nobody Thu Nov 28 09:57:35 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; arc=pass (i=1 dmarc=pass fromdomain=suse.com); dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=2; a=rsa-sha256; t=1673599689; cv=pass; d=zohomail.com; s=zohoarc; b=ZvVhJm53cLS3WQ6jU9p88WHjtQLkwpdSQ6xsFFwjTdJr/NuDe3yjgBgPengeF5zlDHPmzrl2RX7Asvp8mDcq3mALv9LEBD+O+7+7nlxIL7jzrSPFB7w8Hx6TqtKJRykrQEp3Imw7XuA51qZWaOjGrPrO9ormO9ulaCMA/sIzeQg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673599689; h=Content-Type: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=PIN7bYME3B1gixZ9fvJuwYJvOqsQq3RxKGZEx+HCKzM=; b=brgKlissfWkhP5h/aU5wj58vqt356QJiU6MYk+ohZ8Woq7zYFBGTKiBloHR2omr6g/SXHLCDJDEOBsOoV/22aGHQrKqzkDnADSWzkkF7Dbfby/mc741bNFi0d9gtApraqhSa8zOJ9s0OZpuveZ9cQxzN0BKUIv2IDRKoTFxnQGk= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=suse.com); 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 1673599689879352.40742905804154; Fri, 13 Jan 2023 00:48:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.476866.739265 (Exim 4.92) (envelope-from ) id 1pGFj1-0005CT-NC; Fri, 13 Jan 2023 08:47:47 +0000 Received: by outflank-mailman (output) from mailman id 476866.739265; Fri, 13 Jan 2023 08:47:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pGFj1-0005CM-KS; Fri, 13 Jan 2023 08:47:47 +0000 Received: by outflank-mailman (input) for mailman id 476866; Fri, 13 Jan 2023 08:47:46 +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 1pGFj0-00056k-3C for xen-devel@lists.xenproject.org; Fri, 13 Jan 2023 08:47:46 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2058.outbound.protection.outlook.com [40.107.6.58]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f2a8557c-931e-11ed-91b6-6bf2151ebd3b; Fri, 13 Jan 2023 09:47:45 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PR3PR04MB7433.eurprd04.prod.outlook.com (2603:10a6:102:86::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Fri, 13 Jan 2023 08:47:43 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389%7]) with mapi id 15.20.6002.012; Fri, 13 Jan 2023 08:47:42 +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: f2a8557c-931e-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iRmT0ij8gAtOOt4rCEN/vyCQ7Aso5MV0XWank3L9GX8Pm9kdJRjqWx/qqSwvB8d/eNZnZDKpwQFamjhtOleQnz5PVlKfPIbNUt21UtVhKO2ThDlXjEK14uZfOXkOfizcNQ0ZyVj3GUtEq40jNJTdH3FA5Rc3kV0QBoSYM15K72gT81P1NIdMMGRyeysQj99x6ND9ykfmv7FZMsja/efWtUwRHwodik/2u734w1ZHBoFS6ll2lJgdyMac1t0cRSZFtUlmDOn+6/aEOTMvvpZbG55dfOt3Uyc3ahHsVSCzXBYpBl6/CVAsTW2Cm/Mdab15awaPbnJasv9VsEdSJBeSlQ== 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=PIN7bYME3B1gixZ9fvJuwYJvOqsQq3RxKGZEx+HCKzM=; b=CCxguQIoxLhGj1nARBQ3OCJP9W45jvd85jKIXF7a2E6VS4X4lCQ0XYef5nieJIz1osyMAWuZJsulp3drkrt+4LPjlRCesLTlgf9rdbCdx8mDf8HcaWhj3tHy8co6UiBin3eg0ZFEe1SklInxp1TU1+B0sd7dFKFW6lMIveKs7k6MfTpan7laquOBC/AG0jlnSXLRvAXYrpCXLUreXYHFAqcgddHOVfEz6XHrtRG2NxNYQbDO2w9gWDtF/TiozCswnK2NKUDftiti50iKehtCfeILBd0zYYiSXOeL4zHcJTYJT1M2zI4UGrjM17xguo2CTQ9LugHUAUfkG+dvP03/RQ== 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=PIN7bYME3B1gixZ9fvJuwYJvOqsQq3RxKGZEx+HCKzM=; b=5jFDtqWuYfKhs9AEiFfHSZzeg1IMGMKLgqtSorQ6bBlBPqwynqVIFdG3KUrx/wrEuxuPUkPgDzte1DN4CDuicNYasVjmo5WneaZo+gIaKt+EWJa+KfTWAptHhmCK8XaCF4cITchiihyyk5tpEUElofQ87CyclBIXxwOrsb83lhBH1ZE03BU8VMxq5xsr9ALGaVEraOTG2Km+0O7r7ZZS+IPV3yzZ7TpcfQP6jgpNYXFPH20VU/LnQPLMpA6uwQQukyF3BIEtA0gimAtNwZZ/zstNgFXqZAUVuEwTdG2obkMDUKPs9VB8Fml5byY9NmApLz/pD58IVHMfbMubEzBlAw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Fri, 13 Jan 2023 09:47:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: [PATCH 1/2] x86/shadow: sanitize iommu_snoop usage 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?= , Tim Deegan , Xenia Ragiadakou , George Dunlap References: <01756703-efc8-e342-295c-a40a286ad5f1@suse.com> In-Reply-To: <01756703-efc8-e342-295c-a40a286ad5f1@suse.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: FR3P281CA0175.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PR3PR04MB7433:EE_ X-MS-Office365-Filtering-Correlation-Id: c8992c1a-1ff5-48e3-afb4-08daf542d54b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uPegB6XImAJuvmJpNRvfuo3EQ8pI8B1Yz4N6b5aBhPvl3m6NePkT3E+5ZJgz9mxDUqDvspc4sXNvMz+S3nWfJO3EJRm5rG6cpUXq28xS34tZXkZZ9NMPhVPpLPDdMQI7gKK3xyrV98EbrsZRTAcAlo/9ZoTZTt/N7Fa/CQG/jCvifm+RzpDFcq7A/ebzG6LTKiXZvHr/OFyRAR3mq2ooeSy1PDX8oJfLnwq/t0iEknFIhpwGC342jWrSlvmDbSvxuz3QKTMToMMNe93mIKi8mc2V0QSQvGYRQwa4337713lSRNlgX1U+MwKFhE5pikuu0skIkIkW/HYbOcMied8vYzpAQQr+j10mkGxpc1hA3bjRfJLHjt0iFli8Klrypc4J+HZVjavYvQb6m+W2j1o0F4aTzcWzbPgxwJeZF9+IbfwXhq/77Rwfs5rql4SdRE3s2culqMSQLjWr9LwLo8qFVHibRQBKOJk2yJpqATXICRXlsrevKpzaezpElq1yzja0wmd7iYUXXQOJz259KeocV2y3UpFeWmprdb/5QyiuQbAUYc6iDIW9dWpbXwggsK0k/WCguMT3lfyUZXdiXF0+tDF+rZPHGhJifJRDlcTf+ADm4L3ZdnlLTB6KIZSFu3e81Gu8e9t+izt+E0mlxR4jA6iifqQ0jOX/DiaPXW3MII8W/tnn42ZPs/eGHjJJ7n5tyoSJz40cITFouPSnexK7cAKe+dL+lz1prx+b1RjUxRcCfDq7R5N58+VceNNBeIGFvaSg8zJZIpJGifUpEORYPw== 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:(13230022)(39860400002)(136003)(376002)(396003)(366004)(346002)(451199015)(6512007)(6486002)(966005)(478600001)(6506007)(31686004)(186003)(26005)(66946007)(66476007)(316002)(66556008)(54906003)(2616005)(6916009)(4326008)(8676002)(86362001)(38100700002)(8936002)(5660300002)(41300700001)(83380400001)(31696002)(36756003)(2906002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dDVuczl0cWM0VUJrUHlVVnY1bk5rZVU0Q2ppZGY3VHN2RlNOUkhBRVhMM1Ev?= =?utf-8?B?TkQ4UDNyNC8venVNOWJYUWR2TGY2aWVpaTFnNmJadkcyaTgwcjdpOGlOQWx4?= =?utf-8?B?eFBRUExBWExwQjRwaU5RRXF1VU9OWURDcHFTYm9pcFFFa1NjYUNLcVBGT1di?= =?utf-8?B?bUZYZVRwbUlqMjRrZmJVcWtHRDNrd1ZlTFhzVHo1UEtmVTVmT3Ftb2xqMXZn?= =?utf-8?B?bkQxNUp4ZmZUKzBpTVFoVDEvSVJIcDFtMmtLV2Foc3J6d1JDS0ZJaHl3OW9m?= =?utf-8?B?MGYrS3lPbmdranZxZWNTVExCN2hJbWc5SWdjUi9XL0IvNmozLzU0dDZpbWNn?= =?utf-8?B?UXRuYW4zSnBaazFaUVc4QmVDWk8yTWJxQTlmbWloTUIwMEowcnIvR1JOZURQ?= =?utf-8?B?d3V3Q3ZDMkZVTGVodzRuRGNFNitwclZQMXdRL3l2K3Y1V3ErTmUxMWcvd2Jt?= =?utf-8?B?UE5iYUtLOG05bmxRbTFZZk5Id0JaWk10cHo1bXIvYVpQOUdZT3VVdUZxWGtX?= =?utf-8?B?SzZ1dHBQK3NOSEMrVEJMV2xFUkpnY0kza3ZXWWdaSmRrRXZ2bDEwVzBrRStt?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EdHZFAwVU9pTWJX?= =?utf-8?B?RStjazM5STdUVTFxQWdWSXpuRGZobGRjaC9NaldnMGNWQXlXdm9QZnk2SFBS?= =?utf-8?B?RXRXODNQSHZvZU4rRWNORWFzY0tvUXRrZU0xcEdKNHRldFhTL1paVVBiVXRy?= =?utf-8?B?aFZTT2lNQzJUNmRCNnJRN3lOQkxxdjlHUzduTFR6dm8yNE1yZU1Ea0NPVm9z?= =?utf-8?B?NHVaSVUrdmc2UW5Jb1NYSHUrUll5TzBFUmVLY0NZL1UwQkc1amxuUzVaclNO?= =?utf-8?B?Ym9NR2JXc3VyTHFCK3BLRmJKdHA2ZDB1d05UTUd1MEJ0TllSOStFQnhZY3kx?= =?utf-8?B?VjVsYXRvK0d3a2w0Vi84QmVvbFQrSDErK3pyeGc1dE9YcHBDSzVuV1dHQjdY?= =?utf-8?B?STYwTCtoOFAzN2YyMUw0M0orOE1IRkdqOUQwYy9neEtWaTRsbEJMYm9XeTJE?= =?utf-8?B?WXFhTmdrQS9vVDZqUmFLbGV6eXozcmFNSnBqcEMyOGZ1TWZzSVhrOTdKUlFU?= =?utf-8?B?UjVYTVB0K25iSFpmMlZGSVJxV2dDUjdnQkRWOFRQOUMreWUrTWxyQjZNS3dw?= =?utf-8?B?VDFOVlRkOCtISmhqekQwWGZVUjAwVUE2dGh0ZWFQdzNvRFV1YVhDbmc2eTNr?= =?utf-8?Q?wJmVqrocJuCNf/Uzy2tQGlrMh?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8992c1a-1ff5-48e3-afb4-08daf542d54b X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 08:47:42.2906 (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: 4LmJ6pT6TAxMypz69GVfbm4OWgd+10mmUco7RWBX1ljKZzMqSn+8XB3y32EGXqNMUBvoM8UqPvCHwfoO8D2GVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7433 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1673599690445100001 Content-Type: text/plain; charset="utf-8" First of all the variable is meaningful only when an IOMMU is in use for a guest. Qualify the check accordingly, like done elsewhere. Furthermore the controlling command line option is supposed to take effect on VT-d only. Since command line parsing happens before we know whether we're going to use VT-d, force the variable back to set when instead running with AMD IOMMU(s). Signed-off-by: Jan Beulich --- I was first considering to add the extra check to the outermost enclosing if(), but I guess that would break the (questionable) case of assigning MMIO ranges directly by address. The way it's done now also better fits the existing checks, in particular the ones in p2m-ept.c. Note that the #ifndef is put there in anticipation of iommu_snoop becoming a #define when !IOMMU_INTEL (see https://lists.xen.org/archives/html/xen-devel/2023-01/msg00103.html and replies). In _sh_propagate() I'm further puzzled: The iomem_access_permitted() certainly suggests very bad things could happen if it returned false (i.e. in the implicit "else" case). The assumption looks to be that no bad "target_mfn" can make it there. But overall things might end up looking more sane (and being cheaper) when simply using "mmio_mfn" instead. --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -571,7 +571,7 @@ _sh_propagate(struct vcpu *v, gfn_to_paddr(target_gfn), mfn_to_maddr(target_mfn), X86_MT_UC); - else if ( iommu_snoop ) + else if ( is_iommu_enabled(d) && iommu_snoop ) sflags |=3D pat_type_2_pte_flags(X86_MT_WB); else sflags |=3D get_pat_flags(v, --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -56,6 +56,13 @@ void __init acpi_iommu_init(void) if ( !acpi_disabled ) { ret =3D acpi_dmar_init(); + +#ifndef iommu_snoop + /* A command line override for snoop control affects VT-d only. */ + if ( ret ) + iommu_snoop =3D true; +#endif + if ( ret =3D=3D -ENODEV ) ret =3D acpi_ivrs_init(); } From nobody Thu Nov 28 09:57:35 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; arc=pass (i=1 dmarc=pass fromdomain=suse.com); dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=2; a=rsa-sha256; t=1673599723; cv=pass; d=zohomail.com; s=zohoarc; b=OEf8SM/IPXtte2XAjwhGv813aKbkrwvUfqdevvF7ud9VUnampMXmqOxmRDCM4P/gTvTOXOjyRhxnB+h6c5OhVyGZK/3qxsVDgNQAtSt6zbpqVEqEKm+Auamy4KJy2ArQ7gSWLiySxX8XiD2Z/Bw77k8V4J5c5+SrhJGN97y9gTY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673599723; h=Content-Type: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=B1oV9eOFNOGvXVgiJ+rg0AtuPcAmRh13n0oNq2fBO88=; b=UJY4Cg57TaKyciPqWM8wKy7nhJq703MxKNu+WJzvErgoJ5ueDhJWzPslZ3CJ2ldb2bxdX+BIz/ciKLLbRfIrM1YaRrz/uLs8rrHD7w/kJYN9VP94jbStBZ1SnOlXUGyfTa+lUd5OyGaeD+MTHazSS+hMiMBxi1t7MaHpkSRhadk= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=suse.com); 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 1673599723660702.7199597348936; Fri, 13 Jan 2023 00:48:43 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.476870.739277 (Exim 4.92) (envelope-from ) id 1pGFja-0005jy-02; Fri, 13 Jan 2023 08:48:22 +0000 Received: by outflank-mailman (output) from mailman id 476870.739277; Fri, 13 Jan 2023 08:48:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pGFjZ-0005jr-SW; Fri, 13 Jan 2023 08:48:21 +0000 Received: by outflank-mailman (input) for mailman id 476870; Fri, 13 Jan 2023 08:48:20 +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 1pGFjY-00056k-KH for xen-devel@lists.xenproject.org; Fri, 13 Jan 2023 08:48:20 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2072.outbound.protection.outlook.com [40.107.6.72]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 07466450-931f-11ed-91b6-6bf2151ebd3b; Fri, 13 Jan 2023 09:48:19 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PR3PR04MB7433.eurprd04.prod.outlook.com (2603:10a6:102:86::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Fri, 13 Jan 2023 08:48:18 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389%7]) with mapi id 15.20.6002.012; Fri, 13 Jan 2023 08:48:18 +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: 07466450-931f-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mar/jKBke6h4QjhUVgZt3oODFDBI5NYhVJ3TDpb5JhxVcLCKC3rkAxBnephlL8G2RJqqtreyJDgWvWPJkF8JW6foWKwS7PvV+EPgNCt+1eBmQTXhVviwO5RrYVDDAjNK5JXGm/KfYmp4nxAz069sWbeMtY0dYS/Z/4UrC/KJgOMZuLiS5Qo6GjxaQUTn29vIgc9H2sZ8jDDR+Wv6fLrPvqi0RflyYDZlwajIcFkd2iTpTNmt5cozMc15MixvZsWCUO7wE/4/2oZFULtj+SMV8HIdcMcfClRxnpohM3bEbniavHIoNAjkWhU6394O6UJ7fFzrxUaacJEwfCGWJRL67g== 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=B1oV9eOFNOGvXVgiJ+rg0AtuPcAmRh13n0oNq2fBO88=; b=gzlbZV3WLme3h01AW50G8U8F+xefSLtdQ0MLEzqpSS6rFMPnzUpnNkpaJqP+YTTt8AOYfe5pEHWRRdMCQoe4xhphKSq769vaxAjYpxAOMhWz+xN0YMyY5e6yxPA18qbsBiiv6X+s+dqKbBtzAkHtvw48M6cWzTZhBgb1z76hXxwvAsWfo12ab4+lU22/kqr+cGCBczBY48zJeaMjroAAvYsP2dQ0zB7rSrhlwfksyLdxYRprW9DlLuBCWlnVEYyaDuJm7Qs0yWRGE8wR0MGLFgKIGOCvPNmDDUmixQlNz37dw9GDa/jrJsx25AENhYFractcly3jOK7ixZDCQwvzaA== 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=B1oV9eOFNOGvXVgiJ+rg0AtuPcAmRh13n0oNq2fBO88=; b=3W2Z/aB4738ZIiFLrC+Lkq8UnoXohflxiXnf/9Kzs+xl2kgcHicAbpA7Z08Ogi97CrmvnyZnUeG0VYBZYghmC3s/a0cZbMKOaYiUzfQgi40QuQ7/pKXVXO93DE+f4g1I6InKLYxU2Ra73ZOr3GWFA2r1vFN/C59WzSmSkjbZfEE/aMhO2aSXKPNe/BbZ5Zgb91e4JOi34CfzAuYjaBCg/V2lxAd2CEFz0zIYyPXOinU92q7bUARkqdjZYjfEhfCVIibUGqfw1eUlvxzeF81904YW5h7a5asZesB1PyKaWu3RPwZJ7E/XY4JJNkY9j2gLDdSVddGKcIDzBdJ+bTd2hg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Fri, 13 Jan 2023 09:48:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: [PATCH 2/2] x86/shadow: further correct MMIO handling in _sh_propagate() 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?= , Tim Deegan , Xenia Ragiadakou , George Dunlap References: <01756703-efc8-e342-295c-a40a286ad5f1@suse.com> In-Reply-To: <01756703-efc8-e342-295c-a40a286ad5f1@suse.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: FR3P281CA0173.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::15) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PR3PR04MB7433:EE_ X-MS-Office365-Filtering-Correlation-Id: fe3e9317-3c9a-4a0d-ce56-08daf542eace X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: saK4/T8AEIKCh/un8TMOqDgGA3IE30R6OLJ2/fyewo4eYzAKZsCKg/X3O3ehKyrsSGjSpg3zc6pZVPw57HQ/+jRtkKOM3uujBERXrG2Nu7knC+BZyqLXUdyEtm9KeKvopT8G0ebtcezKrYZNg9WwS/M6c27BvEc/+3S9251d8diBAIaKI4EQK534DDbiauhYNiaayw8mVCSGcA8V3gRzOPvqP3ebW4X57edHFMsThNLymmKjqr0vIQDMC15uq6Tn4NdF250gDRCUeAoxyd5nmTpOwN51qNksm0H34wsgTGoWIVuz7oyyuW4yukrii7vrwa0C09/rHVC1ZhKjl1XknrNYDzn8cpTk0IEQ5GE5n+gvOr4Hvv5WBK6lKy+8XA/sH7W02ZNy6AWBUzqudqC5lk7ibY7WN+4MN/Ap5AfuFrhVn/NLQ3CNH+0rThqoNWfYEYRBa/6zBgeu6fF18WnxoXc0awV2Qj473wfIy3qPsaFzv/ysWlBvnzvwh06wSo3Tsn977/xCQPCQR12BrqFV5K4V54J0ESpda8mCJjkerCftH9HBPTfIxNxlBlX94MmuqkK1wFuBz6mUZILb8IzzrPYE6ceDC98DKjuhRYgsJIAJLvBMVHVhPSpmWR8guE6BpZGZM8UUhYHgf3dQcnEV2eyBmyJwwS0jasJZRyRSJC0g97cmGiikTmk1gsqjoQJFFKPREtqrmc/uOHlzIZwjqbHt9yPQUL+zqiF3ZB/253g= 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:(13230022)(39860400002)(136003)(376002)(396003)(366004)(346002)(451199015)(6512007)(6486002)(478600001)(6506007)(31686004)(186003)(26005)(66946007)(66476007)(316002)(66556008)(54906003)(2616005)(6916009)(4326008)(8676002)(86362001)(38100700002)(8936002)(5660300002)(41300700001)(31696002)(36756003)(2906002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Vk91dENoZWZLQUdMdjQvUE0yVGhRN3JXUkNlbTMvL05HMml4VDN3bkkwRC9D?= =?utf-8?B?MTZ6UGxHa29ENXpqODV0b0pNK2QxcU9BZHVHS1B3aDVuRTU2S1VzeDAxRVVl?= =?utf-8?B?QnZDMWhpVlVQWVpuY2pQR2Rqc1J3akVnUjAvM0h0WC9USHZvK041REU2WWE3?= =?utf-8?B?QVUvb3VxQ25uUXJOU1BRNno0RjRkSlFlV2VjSDdpb09zNDJ1WEdBMFl1LzFt?= =?utf-8?B?TlUralFqWXpvOFUwNmxlenF3M2ViWDNuc3Blek9STExWeXR0Ym1vdGFMeDRK?= =?utf-8?B?OFhGbXpUTVNvWXRvNE40Sk1Wb1FENDRJUDZvTWE3S0IxblV0MDNOREExWW5H?= =?utf-8?B?VTF6T2t3YzdrVmVocGtWQjVqbmliakZnaUlhU0QvZExPSUx0K29MM0haaVNx?= =?utf-8?B?NzlDUHRJd2RQUkdSWTR5WmptSWM1d1RYSGFwM253UDFJL2poSW83Ui81L1BP?= =?utf-8?B?TnVBOThwcUpHbHRXb1FrcEJUa2xaMnZTVmdmMHIrT2lhV0hkNXYzYTRrcHhk?= =?utf-8?B?MWhqYVhwU2xOanpGMk5tU1FzRHZQOUhDM1ZyT2U2UG0xRWNtNVd0T2NEQkd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VGtJZkRa?= =?utf-8?B?NFNyZ0txOCtYRFgvL2taaXRYQmZab2U5UGkyaTd2dmF6RVh3VjBEOURHdEFE?= =?utf-8?B?cGRMWW1mTjBTNE40MUFzTXNKRXN4YWxwRE9DenhjSlhJUEdaRFVGYVlqeDhK?= =?utf-8?B?eDRmK1VybHlLMkJIV1ZQVnBBZlBySHhCVjFWbjg3Y2hRZXZ5cjZML21FQTI4?= =?utf-8?B?d2p5WTNaL0cvTmVLMlNpemdIektkT1IvWlNLN1BpYnEvUWZUYkM3MnBYTWJo?= =?utf-8?B?NjRmdkVZc1FBOWVmMzJoODZjRE51RGRCTXlsQ2dyLzBocHp1SytVR29sS1lh?= =?utf-8?B?cm1ENjhCVGFOQnZ6aVMxUXRqZFBHcElJTnRLeVB1VnVXSmE3VjBEWUlvbDUv?= =?utf-8?B?b0owcWFQVEdqdU9ERXdJcFVuODFWQ0FRVmkvdkVQbjg3aDRIL0pSMGJidGxz?= =?utf-8?B?TEFVQktTWTYvTEJlWk1hUVg1UWJUTEYrcWpzNWJUL0NaeTZZc2FGejZ4ZDhC?= =?utf-8?B?NVJJbjRHcXg4V1lPTVUwbnJjL2FkM2VBWlJ0MS9jL0QvWXJFMUd3aDRjNHQ2?= =?utf-8?B?ZFJ4bVY0UjZTVFRXdzFSWUgzNW5Mai9LaXhZZFlqL0xzUmk0LzcyeVA5RFZT?= =?utf-8?Q?jJF0ACAW+4B46P4ooWwUllsUl?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe3e9317-3c9a-4a0d-ce56-08daf542eace X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 08:48:18.4758 (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: fkqqHkz2MxGF8jzFGQoHNK5PjZErFw/5B8+9hOXU9ts6/D0A/rweT187O1WYlsc7U4S7K76VY1dSF39JA+VkWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7433 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1673599724410100001 Content-Type: text/plain; charset="utf-8" While c61a6f74f80e ("x86: enforce consistent cachability of MMIO mappings") correctly converted one !mfn_valid() check there, two others were wrongly left untouched: Both cachability control and log-dirty tracking ought to be uniformly handled/excluded for all (non-)MMIO ranges, not just ones qualifiable by mfn_valid(). Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- Note that this is orthogonal to there looking to be plans to undo other aspects of said commit (XSA-154). --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -543,8 +543,7 @@ _sh_propagate(struct vcpu *v, * caching attributes in the shadows to match what was asked for. */ if ( (level =3D=3D 1) && is_hvm_domain(d) && - (!mfn_valid(target_mfn) || - !is_special_page(mfn_to_page(target_mfn))) ) + (mmio_mfn || !is_special_page(mfn_to_page(target_mfn))) ) { int type; =20 @@ -655,8 +654,7 @@ _sh_propagate(struct vcpu *v, * (We handle log-dirty entirely inside the shadow code, without using= the * p2m_ram_logdirty p2m type: only HAP uses that.) */ - if ( level =3D=3D 1 && unlikely(shadow_mode_log_dirty(d)) && - mfn_valid(target_mfn) ) + if ( level =3D=3D 1 && unlikely(shadow_mode_log_dirty(d)) && !mmio_mfn= ) { if ( ft & FETCH_TYPE_WRITE ) paging_mark_dirty(d, target_mfn);