Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89A3EC433DB for ; Mon, 8 Mar 2021 14:47:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4689461581 for ; Mon, 8 Mar 2021 14:47:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4689461581 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.94995.179144 (Exim 4.92) (envelope-from ) id 1lJHAP-0004Uc-D3; Mon, 08 Mar 2021 14:47:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 94995.179144; Mon, 08 Mar 2021 14:47:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJHAP-0004UV-A0; Mon, 08 Mar 2021 14:47:29 +0000 Received: by outflank-mailman (input) for mailman id 94995; Mon, 08 Mar 2021 14:47:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJHAN-0004UP-U8 for xen-devel@lists.xenproject.org; Mon, 08 Mar 2021 14:47:27 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dc80b3ba-005e-4879-a1b6-48ff5cedcf6a; Mon, 08 Mar 2021 14:47:26 +0000 (UTC) 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: dc80b3ba-005e-4879-a1b6-48ff5cedcf6a DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1615214846; h=to:cc:references:from:subject:message-id:date: in-reply-to:content-transfer-encoding:mime-version; bh=e4GaBLhRKn0ImMER2Gu5f4y+Opc7r9KicYRYk/z1cfk=; b=KtqmuzwVjiE1qObhEtMiByBvq5W7RoAJlPtAHbeTTTKlQIqHLo2IX3uY KXdpXF+ICCjDD6B0V/YGwnLW/VTtSL4QoYPLJd8sXMtOjoQJqaQyguDfH /YhVnJz8+T5jjbFPFTJAFl3nrBBBhcecvI/2+EGwFjerY+lwpZOgtGxUG 0=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: EXBsyg/ePDMnJH5t3evzpqmz54fMtiTQpAj+ifj2RBJ0KjkOGqK2CYpK1he6KnQtEan+TGE9QF vO1PAybi6pvD5xgnV5XQL49AudPuSx80gWRkX9ESK+6XFScPaYjpfa3icoki1teHPPuW74COps T7guhze9ZhVZEwnuVPBr3j37VZFwE4HSAS5DeeXpDYxH5RBXboklnCsQdHSpABi97vjnOALL0u G3+9HzIsGQIe1uT0PFtfLnRFobXNYuhSGoXj9a4AQ7T9FUQqzfue9V1lKRTxurGIaQVCeHOY54 YLo= X-SBRS: 5.2 X-MesageID: 39142679 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.81,232,1610427600"; d="scan'208";a="39142679" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T3LTbmjZL2gpK5K6NmRPLsp+nCez1K94tLIp6a1686hPonmsnr9zLf+Ela04kdfaHf3vRm4kF6a3QKEOba5j+iYU8dR48q0k/S+o0jxw0/ShQR3qbCGUNL6LTEWGoKd6JtHTQQVwrt+IrCWPaBfce+J9p0z26Wj8tN33aEQZOgg/qNGaB7Z4TvYQm61fV08iL2YglfxAlQRw52ShpOQZw+7jPMPqJ+JDDsI6jM0G9Hx4e49BliGEbS/5iS8dww6ZW2ClH76gVHa8yPvRfNHE5G6v3s8t3TEgCIH7CEqzshhKsXJLgCWVW2MyBchUuzMsY3XKxvbpJ+tWiZse1tO8Mw== 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-SenderADCheck; bh=e4GaBLhRKn0ImMER2Gu5f4y+Opc7r9KicYRYk/z1cfk=; b=hXaxvWMqoNGwG17XCFlgcwSffHhE8A/xz5JfgFKq70STtYnLjpre/ZvIdVbjgsVXNEZtU3bJVF23WJjJxbNaunH2rSFjnBejXkdIM59LcWH8ZpR/jy/wNINbgMXneDVuD/hyjdyunZhe8J+BLzEm8CczH7hqeoJnblDdU+3MwFMG/4971UwiFvp8wBAx5c7iVv0Khq5MmSA8mrpQSBKqUD/fCs5UR0up/v0WFKTrPgNBwf2LSfvrR+V33UWhO4e4qU0Fkh0yBVLa5w01YWxkhpVD0Qv0MINZTGAugqCE7VKC04CB66ktRFMxZvTcsWfyWUOGu79jJs+xihz2X+PFiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e4GaBLhRKn0ImMER2Gu5f4y+Opc7r9KicYRYk/z1cfk=; b=DktSnJQleUlAYVloihOczzgkz1j7lqkZIOsDuFQuZY1SRRQ7YogTd2h5jeWNtQjjPu4+5Vf1x98P8S6WafdU5f5JSkgwLOykIgwbe+1OEMF4tHSAbnekLhv2tTP1WqRMd99G88Y5RLZ+/5DBuQRnhdygP3VJeszTiZAyRvKQ8Gk= To: Jan Beulich CC: "xen-devel@lists.xenproject.org" , George Dunlap , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Ian Jackson , Tim Deegan References: <3bb90ab6-22c9-31d4-88a2-39bd3d81c2d7@suse.com> <96c83adb-9e81-8398-c905-f4f0730ba240@citrix.com> <8fd91411-ecb7-c0ec-000a-b1937c98f57e@citrix.com> <55964b2d-a826-710b-1814-c68eeebcc891@suse.com> From: Andrew Cooper Subject: Re: [PATCH 1/2][4.15?] x86/shadow: suppress "fast fault path" optimization when running virtualized Message-ID: <439bb00e-b279-d5db-87e7-72ec6ac9a316@citrix.com> Date: Mon, 8 Mar 2021 14:47:03 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 In-Reply-To: <55964b2d-a826-710b-1814-c68eeebcc891@suse.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-GB X-ClientProxiedBy: LO4P123CA0434.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a9::7) To BYAPR03MB3623.namprd03.prod.outlook.com (2603:10b6:a02:aa::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e5728e5-74bd-4b4a-fb9a-08d8e2410da1 X-MS-TrafficTypeDiagnostic: SJ0PR03MB5597: X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E5CQG5raJzhT1j+imng7RpjQgXP7IEgBfylYb/9qGtwt6ognouhK2ZDRQvwzO7dRkrWpQtT9xEYO25HixbW/O8zK3pj3IVAlXzOGuXwpbdcHQobz4RM9Hk4arxvoFblLwQ8jfYdJTxK/OF9bdXt4fZF+Pb02LkK4q/LLS5OzJiekgyA6Yk+iwG6rMSjU3HCNtvqdTJxBHIZ/30di+toY8Sd9dRXaHlE8GBKC6IRdX9saXwF/RSp/+sL0E4Dx9imQ84Wamk1cZMwxHoOCHSP1faBzD9onplVd6UuCFENyJivCTRJXbmBt9VZvUl8pytUy8fMqnwyBO4yBiNXZgOdEqCM3m5xe3bSv0bTM2bGGp0aFBeMN4yYba+bWcQ+ItmuRtIxS8QbBC1VH8TuoxiwA7NRxNyMSPeNrWFGsKZmfHu2K1mbPXf+7amYzau0aTECbdQeFdo8vkaLE7ccYpbZndLBV2LPN3KnkBTvh22TUuS5r2Bmr5tGFWYHyUJpYoDZeRHxw1otFy8l7kzjhEcILFtLNcQ10Hu/YS1BpOyVrPR3Elog/8T+yoVdnmLcZuEui9jNo2ZTq+Yc19MY55C+FbHG7UhEJ0JhPuM9dNaxDQ8o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR03MB3623.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(366004)(396003)(39860400002)(136003)(376002)(36756003)(54906003)(83380400001)(66946007)(2906002)(5660300002)(6666004)(478600001)(26005)(8936002)(8676002)(53546011)(2616005)(4326008)(86362001)(16526019)(31686004)(186003)(6486002)(6916009)(956004)(316002)(66476007)(31696002)(16576012)(66556008)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?S2lJcWdPSDB2Z1ZkSk02dThjaEMrZ1E4Q1VYN2NCSFZJNUJITzRSdmpLa29K?= =?utf-8?B?bjZ4M0hnRGE1bEVLLzA2OHpIUlc3QWxpUkd2VkxhRUU0eDk3Rng0VUk5d2Fz?= =?utf-8?B?QURERGl1Kzh5SzEvc1lKeWo0UGlGRVVsQ3pxZ2R0Z0xtRVg3S2g1S1g0K2Nr?= =?utf-8?B?QkFOK09KMnptWHp4TUo5NmlEUE9OUHJETmpzTWJUclNXV1FHN3BYR3poZ3BY?= =?utf-8?B?MnFYNE1xTFpEaVY3dURDOThEOXZEcTVXNFhSalRXYnNlOHhtczZHb1BlOFM0?= =?utf-8?B?Z0NOVnZSMVcveXVRS0xGQVp5U3VNN0MvRnAveHdLSlgrZTYrWDd2Y0NBcG9Z?= =?utf-8?B?Mi94bi9MUGtIVGQrM2lHdjFhamhoOXFSNkN0bUQvSm9NU09BNVpkdHRWaElq?= =?utf-8?B?alhacjJJYy9henJXUFJaRzNHWmIxS1U2QTdpSlFlbjhtWlR3K2JmZExQRGl4?= =?utf-8?B?MUlNRFk3dXdKNkNtV05Gd1lSbTBocGxUTGhBeW0zdkNTbkkzWWJ2OTZNMVpm?= =?utf-8?B?cWhPenlZOXlwZFF5dnFpY2h2VEZ6Y3FGTjBlS2wwSjNTZktocGZtUXVFRFox?= =?utf-8?B?UkVaalJzNitLN0xXS2tlZWpLM3NKUVNkSG5lbVhjOTJwb1cwZDJKTEp4ZTY3?= =?utf-8?B?MGlnaGJZQU5ZcGc3TDZqWEhkUUxMMjNTbjFZTTJINGV0TFJ1R2JLanYzYmRM?= =?utf-8?B?Q2ZXZ1JPTWR1T0lMZjA1eG1iNFZMR29PbXIycjRQa0ZJQ2drWVN4Ni9WdEF1?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JkSXMxQWh4Z20w?= =?utf-8?B?cE9hWkNWK3pBMmhzT3hPRSsySVRkR09Jb3QybWd0WVhJckFRWjhUazNFeG13?= =?utf-8?Q?fihUMs4b15AbRaTUQuKN/u4OGmavwVCuD1mvJKb?= X-MS-Exchange-CrossTenant-Network-Message-Id: 7e5728e5-74bd-4b4a-fb9a-08d8e2410da1 X-MS-Exchange-CrossTenant-AuthSource: BYAPR03MB3623.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2021 14:47:10.4175 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gAtM57ye3bZGtibcaYTe/jqagb9C0O0gqJH5pEtsp6hJPmQNgGLBt7mFDWCZxwL0agDRwUB+omCZAAchy6TvRleZRwjaaGbkL3P0n03/ems= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5597 X-OriginatorOrg: citrix.com On 08/03/2021 14:29, Jan Beulich wrote: > On 08.03.2021 14:59, Andrew Cooper wrote: >> On 08/03/2021 13:51, Jan Beulich wrote: >>> On 08.03.2021 14:47, Andrew Cooper wrote: >>>> On 08/03/2021 09:25, Tim Deegan wrote: >>>>> At 16:37 +0100 on 05 Mar (1614962224), Jan Beulich wrote: >>>>>> We can't make correctness of our own behavior dependent upon a >>>>>> hypervisor underneath us correctly telling us the true physical addr= ess >>>>>> with hardware uses. Without knowing this, we can't be certain reserv= ed >>>>>> bit faults can actually be observed. Therefore, besides evaluating t= he >>>>>> number of address bits when deciding whether to use the optimization= , >>>>>> also check whether we're running virtualized ourselves. >>>>>> >>>>>> Requested-by: Andrew Cooper >>>>>> Signed-off-by: Jan Beulich >>>>> Acked-by: Tim Deegan >>>>> >>>>> I would consider this to be a bug in the underlying hypervisor, but I >>>>> agree than in practice it won't be safe to rely on it being correct. >>>> I'd argue against this being a hypervisor bug.=C2=A0 If anything, it i= s a >>>> weakness in how x86 virtualisation works. >>>> >>>> For booting on a single host, then yes - vMAXPHYSADDR really ought to = be >>>> the same as MAXPHYSADDR, and is what happens in the common case. >>>> >>>> For booting in a heterogeneous pool, the only safe value is the min of >>>> MAXPHYSADDR across the resource pool.=C2=A0 Anything higher, and the V= M will >>>> malfunction (get #PF[rsvd] for apparently-legal PTEs) on the smallest >>>> pool member(s). >>> Except that min isn't safe either - the guest may then expect reserved >>> bit faults where none surface. >> Such a guest is buggy, and in clear violation of the rules set out in >> the architecture.=C2=A0 All reserved behaviour is subject to change in t= he >> future. >> >> Any software (Xen included) deliberately choosing to depend on the >> specifics of reserved behaviour, get to keep all resulting pieces. > While I could understand what you're saying when considering our > prior unconditional relying on getting reserved bit faults, are you > suggesting the recently adjusted behavior is still "in clear > violation of the rules set out in the architecture"? And hence are > you suggesting we should have outright dropped that optimization? Strictly speaking, we shouldn't use reserved bits at all.=C2=A0 That is the most compatible option available. Given that we have chosen to use reserved bits, it is our responsibility for ensuring that they are safe to use.=C2=A0 That is why we elect not to u= se them when virtualised (for this bug), or on native when we think they won't work (the previous change for IceLake). From that point of view, I think we're fine.=C2=A0 We're (knowingly) operating outside of the rules, and now taking appropriate precautions to cover the corner cases we are aware of. The behaviour of already-shipped CPUs, while not architecturally guarenteed, is known and can reasonably be depended upon. ~Andrew