From patchwork Tue Sep 21 07:16:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507337 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 EBA01C433EF for ; Tue, 21 Sep 2021 07:17:01 +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 93676610CA for ; Tue, 21 Sep 2021 07:17:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 93676610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191394.341405 (Exim 4.92) (envelope-from ) id 1mSa1M-0002fH-HR; Tue, 21 Sep 2021 07:16:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191394.341405; Tue, 21 Sep 2021 07:16:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa1M-0002f6-CF; Tue, 21 Sep 2021 07:16:52 +0000 Received: by outflank-mailman (input) for mailman id 191394; Tue, 21 Sep 2021 07:16:50 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa1K-0002Od-D3 for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:16:50 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.111.102]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e28fbe3e-1aab-11ec-b89f-12813bfff9fa; Tue, 21 Sep 2021 07:16:49 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02lp2055.outbound.protection.outlook.com [104.47.5.55]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-34-phiF_01_OguB7cRVDHqGJA-1; Tue, 21 Sep 2021 09:16:47 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR0402MB3389.eurprd04.prod.outlook.com (2603:10a6:803:b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Tue, 21 Sep 2021 07:16:45 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:16:45 +0000 Received: from [10.156.60.236] (37.24.206.209) by FR0P281CA0057.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.5 via Frontend Transport; Tue, 21 Sep 2021 07:16:45 +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: e28fbe3e-1aab-11ec-b89f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208608; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Vo4Dkwt5tDPO7OINdISKIs97Cf1OIMtewg4ko0cXdk=; b=YLAmMJql+qviZW2w0sm47awS0gK6CbF53dEHYt5tZAwGVP3guQ4xiK8BN+nAtRKOrpyYxX 07MT292TFUwmr3p+X9bzeBLSSZ1oJ25mcXJO1LOx+1Hc9f7hFMTm8cuvFpsOJZkvolRn+s oMnxRu+pmb+49nKmikMYK6yYogbRs4Y= X-MC-Unique: phiF_01_OguB7cRVDHqGJA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NQgFmurlxHLmi94LsZ8bEGJ7Ek0Pib+n055OwWt5ZFrNeep1aGnFLPcaqLl4u3EvOKoT6Q/+OO05Kte9sXPgziaqbu5dajxisVdILiUEoAGsTpRyGy1PkURQekqIdESU6THCf2Pz3mIopKyozCT23ruxLfG6otD9HAzmAZSGSVe8iSB9bo/TJfsgKcEp/QNfc6Lu8VvtV+5IEGMD8sTMI4ZlZj4r/4NzrAIGkzQaY3npNG8ub+9LvweRgfhiqjQmt0J2Lx4LU8XmTm7nTS8BSVkTBDQLzZZQ1wpw64lfCFzPdpVinXZeb2bqrqy8zBHbU2bjdl044DEFwbd8A5Chyg== 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; bh=4Vo4Dkwt5tDPO7OINdISKIs97Cf1OIMtewg4ko0cXdk=; b=c2yTQrNPMpRuTq6SdKe6cOk5q7FGljzNqbvgLWIpJ9t5eON8icAfUDpbrF2vt/qzc1Q890t9uGVj3awpgDaGl9SOkkw3DZDIAIxxoN7fBSC5fBREi3VFd1URZnes2cCT0JNaNbZNGWymymNC6cGm30PUdHBN1o3uiB0n5yMYRZqM9o08XFLlfSs32Gk3VFCUuhf+iJZiN5HwMj/ENvVD8xe9u7/Y2i7ZNpmhRMF+pXyKkhGfQYAsZ4oFaxEyAGs1NYjl7IPYTuN4SNU7jnAyeWqKWZeq0qbB2tVOPjgOD/GHLu3VTPi0SPAawwtdBk9+NRAOzj4+DscgWRr6ASeTrA== 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 Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 1/9] x86/PVH: improve Dom0 memory size calculation From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Message-ID: <562a9ee5-102e-ee25-e4cd-721e44b7409a@suse.com> Date: Tue, 21 Sep 2021 09:16:44 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: FR0P281CA0057.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::14) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4d41e5e-993e-4b71-1358-08d97ccfc503 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3389: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yf6NHN4kfoXQ01MwY35MpmQYsPfONxiyB/+OG0nf3x5frssgcHSO8zvp48//ght2cHYywtALvtBZj+PPm/U8YIZbL4K/uFov2XKc6HvSQ+MpfcHq8+fEUUQPujC+tx7Tha7mD76nRpUcOcg2NShaDg0cKI8ssT6nG7XpDF0do54+1qldebmypfUCo7AsgbcUH7RLKKyY7m44yUEAOuLNFyiGYI1ZSHGBRiT83OiKBHq0vI0DNLbV+n/cS5YFtqomEhJYepv1GiBm1KUpOm8sHUubw418MQ50eS5n1mn0FK7OHX35v+IMQinNQJ7da4JMwR3kSLvEFHEomi1wZ8sqI6u1A+OdkT5TUpGLumc/ljPZiO1ec4Gpm4b1z5Z+77toW11Pya8XyF0iMVh6OodGzMoIc4f2cBp9WiADxU/cVQQib86ZIrq3961L/FupPPo6gJjnFSoPRrKT+ABN70ujus20hJSSTx1L3edMq+rC9lCbIIA97Nq9FSA2TUaCDb216XbcqfUCZZIuN2kil/zTYxV7cVfyn6EQFuHxNYqSEjHujmj75pyHLGmJiv9iYvwe7Nh/barK2pOV5l3s8gXHvY4d1zuP/xFZ4bwA1kghMt85C5/tRWJOjsSJKSakRr2gYq1EfDoMD8lnNurMNIWYPB0D6GdTBhzJgVcMaMuAh+IWyy9myWZKxrQcG779ezds2oWK870c2fzqhSE3dDwSworNrgPZbeQxPefOr+kOcPVvEwZwN/iKvyJ0kki9cLqpqqY7hPrfAXtarJuWzU0k8A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(54906003)(6916009)(2616005)(4326008)(956004)(38100700002)(31686004)(508600001)(36756003)(86362001)(66556008)(6486002)(66946007)(66476007)(83380400001)(316002)(16576012)(5660300002)(8676002)(31696002)(2906002)(186003)(8936002)(26005)(25903002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PPiZ/Obd2putUxaW0CehuS8eou8K?= =?utf-8?q?k+1to70UmdnKo4WGqitq7aVjm2hTUsb1GpZYkCAn2ZuMvl3xKfd47o6RLpK95pWk2?= =?utf-8?q?OLWpHynXuztp4VWZZF7LLic1+tSzKLFeNA3gSe54rS3uORF6gztRvMQ0PkXM4rHvn?= =?utf-8?q?6PLoytbI/jCpS149W7DW1j6VxBlCXUcfRD8MHBWp4PyhO0HDKp37KoJoeqRy+Xnc4?= =?utf-8?q?dsz4wPh94YfkZRxlSviShTvrIRTYfEeFG/1V1awJBzGa4PghYTGGaVj6SkzJIPjB0?= =?utf-8?q?7aeucyYrGJsnMJeF9qZakiJz7nyeDzRCiMaFiwsxJbQT4hI9IQq6xBabJWYf1qmTl?= =?utf-8?q?0HuBzpurqBPHNAxMDnStjuzkw29So3v8eWBGN/t/yImDFKHlkbzLYWwLqVU/aoptp?= =?utf-8?q?Wi7DyiV9eSk49qi/nynjtpU+Qqrtt1kuS8J2RqSyEWdIy4b8WSlZo/Zh+g8v/52Dh?= =?utf-8?q?RHIga3ns1L4oaG79SKgO136OvqsAhy/hj4mEezSD7lICUm9j1d4YjgMj8u53yOXw+?= =?utf-8?q?rSQGWQfWd2wqnAnRqJ891xeaH9r9QgIs4OljywWhCUSVJwKUXlSIRFKbJC419rXOC?= =?utf-8?q?wdEcunwRaS1qB5n2fCbsepsHfpI39DlAp8htDvd0d1T/aFtni9iaKiwA4DCFAI8CL?= =?utf-8?q?nwQPSjxleP1pWXEb8YssuWcYdsjX/wkwgpT2Pm6VRh4OkEoAF9lx3bldgi8MjcRz4?= =?utf-8?q?A0D9QvIGmmjkcDJczP/WBfKRpuifNNSoLSC2nthaVTqBT7516bT2iqKrT3jUi/rZK?= =?utf-8?q?/1LebDiiGAVaxRWhMlLChbemWb+DYqWqITwyhES7EHOwH3xtoeEtO3DjHrlVPRS9G?= =?utf-8?q?J5hQkiqJtI8f5KnOPTa3pL8zzE8aaUv1W8zBkGm7AYMg3LrIpxQcRYhZxI4giFiLe?= =?utf-8?q?v5ql0PTmGqLiFnLQdG3e9EE6K1K1LlwMKhekGB9K8Ab/kiWBzaJDeutgNuMzgExk3?= =?utf-8?q?HftZ1w3JqW1+H1GSUc2NfZPjTPu3I/oKJm7dV8hs+1aLPTWb8n0ZDa6QehH9+7UNX?= =?utf-8?q?Agm2k3x0okse3po6yXZCzwkLLS/XZ6s27HcnM/tfWsC7Oesh9FtnbQpAPPZ5QK4Bb?= =?utf-8?q?VhrwAzAciVRnKWxQt4wGm8h/ZUBb+wF3k7BumlQmlqyeAnSh+dVP1vZ/zdmHfffHE?= =?utf-8?q?01tgCsVIn1Lnvn66T7AaZJQR1Qo0KBp5q9qQfzmApP2VE3YookECvD6xdq/LRAyU/?= =?utf-8?q?lcoQA1+K18zSgP6PPf/DK+1BwzN2MHpoYPX8dpEfakPfBfyfbZ6jOLdnarADD3Ny3?= =?utf-8?q?aKQNxx/bpBRFj6zQ?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4d41e5e-993e-4b71-1358-08d97ccfc503 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:16:45.6312 (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: YntyIQd1iNOYuPWSIaiqG8+4bSQuZKrR9zUKfLEBuSP1svBKhAIk+7aZYY0u7RhSTcacDa9fXkNHJXGpljr8bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3389 Assuming that the accounting for IOMMU page tables will also take care of the P2M needs was wrong: dom0_paging_pages() can determine a far higher value, high enough for the system to run out of memory while setting up Dom0. Hence in the case of shared page tables the larger of the two values needs to be used (without shared page tables the sum of both continues to be applicable). While there also account for two further aspects in the PV case: With "iommu=dom0-passthrough" no IOMMU page tables would get allocated, so none need accounting for. And if shadow mode is to be enabled, setting aside a suitable amount for the P2M pool to get populated is also necessary (i.e. similar to the non-shared-page-tables case of PVH). Signed-off-by: Jan Beulich --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -318,7 +318,7 @@ unsigned long __init dom0_compute_nr_pag struct domain *d, struct elf_dom_parms *parms, unsigned long initrd_len) { nodeid_t node; - unsigned long avail = 0, nr_pages, min_pages, max_pages; + unsigned long avail = 0, nr_pages, min_pages, max_pages, iommu_pages = 0; bool need_paging; /* The ordering of operands is to work around a clang5 issue. */ @@ -337,18 +337,23 @@ unsigned long __init dom0_compute_nr_pag avail -= d->max_vcpus - 1; /* Reserve memory for iommu_dom0_init() (rough estimate). */ - if ( is_iommu_enabled(d) ) + if ( is_iommu_enabled(d) && !iommu_hwdom_passthrough ) { unsigned int s; for ( s = 9; s < BITS_PER_LONG; s += 9 ) - avail -= max_pdx >> s; + iommu_pages += max_pdx >> s; + + avail -= iommu_pages; } - need_paging = is_hvm_domain(d) && - (!iommu_use_hap_pt(d) || !paging_mode_hap(d)); + need_paging = is_hvm_domain(d) + ? !iommu_use_hap_pt(d) || !paging_mode_hap(d) + : opt_dom0_shadow; for ( ; ; need_paging = false ) { + unsigned long paging_pages; + nr_pages = get_memsize(&dom0_size, avail); min_pages = get_memsize(&dom0_min_size, avail); max_pages = get_memsize(&dom0_max_size, avail); @@ -377,11 +382,20 @@ unsigned long __init dom0_compute_nr_pag nr_pages = min(nr_pages, max_pages); nr_pages = min(nr_pages, avail); - if ( !need_paging ) - break; + paging_pages = paging_mode_enabled(d) || need_paging + ? dom0_paging_pages(d, nr_pages) : 0; /* Reserve memory for shadow or HAP. */ - avail -= dom0_paging_pages(d, nr_pages); + if ( !need_paging ) + { + if ( paging_pages <= iommu_pages ) + break; + + avail -= paging_pages - iommu_pages; + } + else + avail -= paging_pages; + iommu_pages = paging_pages; } if ( is_pv_domain(d) && From patchwork Tue Sep 21 07:17:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507339 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 BAF3FC433EF for ; Tue, 21 Sep 2021 07:17:28 +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 712E060555 for ; Tue, 21 Sep 2021 07:17:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 712E060555 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191405.341415 (Exim 4.92) (envelope-from ) id 1mSa1o-0003gy-Oa; Tue, 21 Sep 2021 07:17:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191405.341415; Tue, 21 Sep 2021 07:17:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa1o-0003gr-Le; Tue, 21 Sep 2021 07:17:20 +0000 Received: by outflank-mailman (input) for mailman id 191405; Tue, 21 Sep 2021 07:17:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa1o-0003gY-3q for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:17:20 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d06a7d7c-9448-43b7-917e-8e7aa29e0d04; Tue, 21 Sep 2021 07:17:19 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2171.outbound.protection.outlook.com [104.47.17.171]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-35-3s8Ti9AIMfarizSjot36hg-1; Tue, 21 Sep 2021 09:17:17 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB3293.eurprd04.prod.outlook.com (2603:10a6:802:11::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.18; Tue, 21 Sep 2021 07:17:16 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:17:16 +0000 Received: from [10.156.60.236] (37.24.206.209) by FR0P281CA0059.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.6 via Frontend Transport; Tue, 21 Sep 2021 07:17:15 +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: d06a7d7c-9448-43b7-917e-8e7aa29e0d04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MFNiMXoiKa06wTzVJFs8SMvmLCcjsyrCF6I15nLpdgY=; b=T8G82C8rBXnrXx4dNUCfLqoFZgVfOZ34RFARepyjE9AYal5RVlIpojY8yE3dsRijT1U7lx QmBaBFzzoY/tGjs4BiGUEftoEkoJxWOpBCvH9RBAfd7F8dpCrFVoGvSDzAkGMS6rAh/qz9 C8qiLYncYnec74vggrc4qr/kcIQl5Xc= X-MC-Unique: 3s8Ti9AIMfarizSjot36hg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S0pYYLv5LZzVYX05b16L7+HauN2z3XNp7O1xn0TLbo1Wby8DTpgRvZrw4KLuPs1uq98Mun/YJrZBQ2WWXuSJYWNRnxWNka4ICRkdmOxNWrp+Mv9UmJE0DbyxoKwPnYgZq5KbLzfrPzyNVSQ91cqSUiFJdnkR8VB2856ASiJovltcWztKi673ry5W5f7FPsLbgqavLEb8KJoklsiogOhh7AAHiIwRLTeiHS8mintk35CvOyj0O6H9WYnUWaavURpezkV59mA5wg/lzEo/qvkxUXbY/86h4+3aVRFu3IlOT6r8OzJtze2tvWGbiGUJl7eBMwn3shmDCPiFFy9u7Ql9Ew== 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; bh=MFNiMXoiKa06wTzVJFs8SMvmLCcjsyrCF6I15nLpdgY=; b=AHXntWIYCVqrxmvAEZmvpYPPCdZC6BrqTI3wc6Sqj5TbGEdtsFrAoBG/xOT3e3dVhneAUBWcaqsam0fNxVevcRypQc6dadj0pPOxfH53Ey4vWMBKf5znIGPE5A6+o9NWqb0cjkRDHEJ4xkr7eDctQ5GaLVsR1yDXw33Vaz0a8OA5abV0hQEl6Jgh+8jFnS6LAI7kOxrjFGa6b2yUWuzkUM96oo4EnjiHAeVOH9alUp5GgWPI399J/2cvMUA+rzghceLz2CzBx3ycFpK8Y49+4js6dtf902vKaR4mU2rOQdauiowiPEMV/7TPhk+U6G2He6smGHQEzumKIHPcR6Cx4w== 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 Authentication-Results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 2/9] x86/PV: properly set shadow allocation for Dom0 From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Tim Deegan References: Message-ID: <25958e72-40b9-30ef-a348-6ac9ef02b261@suse.com> Date: Tue, 21 Sep 2021 09:17:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: FR0P281CA0059.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::7) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b117088e-0409-41d4-e185-08d97ccfd73a X-MS-TrafficTypeDiagnostic: VI1PR04MB3293: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VV4IQ4OoTE21WTgek+id9N1AX6i11nUc/sdCJYlQ4Vv++TSyN5VNDFYCFuV9kB5j2GnpmJK4DQyjLz9k+3QxTl5cUpGOvo1w85S6K4IN2Jgrq6CUDraiu0eZ3yAZ5aeiitZuWXUHDprDtAyPkh8X+fvCm2Eak3ZV+wmuEwyAHGL8SIUqwj4hBLtC/VEJT8YKS+mFuVsrTY6I1/4beV5m5kZEpkvseo0CWzLABoxAfNr2mUbI5FuzrM1j8Y4fJaxLIxu7lx7EgXgDTTc7PrmvS005a+uN9eqUWnmLWbtZVm3/rT7AcDoWah4crSfsnMDP6IPS0inXaih6Ydw17MrfPQi9jGBr2uc/UIbbKqUJmnSTCV4sfgD0CM8er54a8/B+HSqxrgXnvGCSmh0OOV2kLcRIK01Ib99pd6WlSVu4AgG4c6SdVGzxUjClY8eSj1T/TXIzUcFuwW+XGmb9dfmZ53FiS+/683gHYUhAqrdpXAVVY/dkl9uJYZN6AKcLA3wYSgjrNL9U+vacVZ09+3pD3XeeSe4USMoU96NblXnZXfXtDnNLoMhj2G4ooyf0qJ1XWo7Ks2YJfjFFHWqpDCL36OdXcdwIiWwDMYFaNC6W4fyURyZmDG6lAGOnaPdB+shTWlu1/SDo/aIolUaslxTR+SD3VLjtdSiOxDqWnB2ZW+AFKUTtjBntNZFhgmHb/yp7jBVsFGw8SkRF0gYb1yuHFpfjTitWUm1UtYLhrKpRQWw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(16576012)(316002)(83380400001)(31696002)(8936002)(956004)(36756003)(2906002)(86362001)(54906003)(31686004)(6486002)(508600001)(66946007)(2616005)(26005)(4326008)(38100700002)(8676002)(66556008)(66476007)(186003)(6916009)(5660300002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?a/fROiN8FEJuGaNqlUlp9y4rd7Z6?= =?utf-8?q?zDKjolxmEYQ6YbdRDTxo29ByunfU8qUJy7TxoA0EHYN6LHPJkvU2Dx1XOR7Iw8TGF?= =?utf-8?q?vEsDaw2QULR0j9UK8zD4PeMC1e8uf6K0u2bvNTETwSbF5H9OKckPUFUlYpcVj88Yd?= =?utf-8?q?HtbUVzVf37ZD7LQBui2TgsLhiovm55xUk55OZgteSy2UCq/04DTwIz+MJraJs3iJ1?= =?utf-8?q?zeRRdNJBGAjbW2+5Eu3ioa0DgOVuFlxMalem34I5BqgutXSAqBFzR15/hbqGuSlce?= =?utf-8?q?i1tnu80wuUu/a0/9jIWNK0XExdBErFK1KnL3xREIBfAo/iPmY8odNLFuzwIa/5zXq?= =?utf-8?q?kQmVMDp+QJi7WQVoc3/Po/cRg71R9iE/QFpmU8sTSmDsmrE7PwTOJeaIwNBVDdTYg?= =?utf-8?q?ewYPfLoBvALjM0Qjg1X0uEhSu41VIdtQNBL4qXxlLUmR2NVA8z9P8yzRR5b07cuEF?= =?utf-8?q?xnNneri0jRUSq0oNi3zwPAL1XrN42MAwPBVnSeluicSbZJklrnM2FQO96p/HOjmHa?= =?utf-8?q?DcMtdWtSMQUIBjOrHMzaYeXly251qPUN5UFPJgXhKmVcSkIGDX1HfmFatYApphhcH?= =?utf-8?q?y+RyuJqldKExnWjJs/c/V/2BGIiXBTiQxZfsjP3k2PjD/FVvx5z1IALMs+zlCYwX0?= =?utf-8?q?gMyXdhO+PkB5vdMbndmbl2MhVKM7Vo+kQ2Wq9IOwwPVC4ssuz39Ci4lGJQmWHIRon?= =?utf-8?q?N49O7cgarli+aRPfvpes3S4MorYT9D1A2U8OezqImX/xtwxDKKH98ZZuigVkU5KTl?= =?utf-8?q?20z//OnwkU2nKNz+NoIXZs4Zn59dJQnJ/e/fzJzdGtuZOP6Ts6KLK5p+CoEodztus?= =?utf-8?q?cMfLj0HXAF8vzRy4Q9aBNN5Q3rXsvZJkcQbpfVHEu6PHSV2XFGt8JgYD7rDO8DERl?= =?utf-8?q?7Ulc3wJAe9K6WNCbxb9FOhEPwmH55h6+INqhmvqg1ewM7jgiT4GT2H7YlKHsWAPWT?= =?utf-8?q?JSRrZMwZDIFxM/JQnoR1DM+9jtzNABoAmyN9sQILg4dgWz5lxAlb42hFVlnj9ucr8?= =?utf-8?q?ooz3ri6545WtsZTTQKrstXWoWM5KcerMhlrQIbkufRL+r8qeKlkUtzhyCDC/Zz3Oj?= =?utf-8?q?S/6MtglROmlw81pucl7s+PKcWWBAfcd+5Yeve4iABxss1sUk2njDIzN9qTISR0CqS?= =?utf-8?q?KFabGay7YWJtwdLOJ4u/M8qfZLP64EJyqSBhhVUDl7W5hGtM8RmMvOOwQjt8z2/Pv?= =?utf-8?q?vFujEVR3yBNyZlaYhExcobhgc9wDdVqOqJkkpj565nE1HbRgthSY5SC+WqWMCV6rF?= =?utf-8?q?XOkxGi5FblTPclpm?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: b117088e-0409-41d4-e185-08d97ccfd73a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:17:16.1969 (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: JZ3n+cYOVUDjh4563IapgqOAZe7RFOXUImThO7pp29Y4ksrd56iE9GMzOXgm9lDW9f4tTIDR4kHhGcFfam5mBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3293 Leaving shadow setup just to the L1TF tasklet means running Dom0 on a minimally acceptable shadow memory pool, rather than what normally would be used (also, for example, for PVH). Populate the pool before triggering the tasklet, on a best effort basis (again like done for PVH). Signed-off-by: Jan Beulich Acked-by: Tim Deegan Reviewed-by: Roger Pau Monné --- v2: Latch dom0_paging_pages() result. --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1298,7 +1298,7 @@ int shadow_set_allocation(struct domain { struct page_info *sp; - ASSERT(paging_locked_by_me(d)); + ASSERT(paging_locked_by_me(d) || system_state < SYS_STATE_active); if ( pages > 0 ) { --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -21,6 +21,7 @@ #include #include #include +#include /* Allow ring-3 access in long mode as guest cannot use ring 1 ... */ #define BASE_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER) @@ -933,7 +934,18 @@ int __init dom0_construct_pv(struct doma #ifdef CONFIG_SHADOW_PAGING if ( opt_dom0_shadow ) { + bool preempted; + printk("Switching dom0 to using shadow paging\n"); + + nr_pt_pages = dom0_paging_pages(d, nr_pages); + + do { + preempted = false; + shadow_set_allocation(d, nr_pt_pages, &preempted); + process_pending_softirqs(); + } while ( preempted ); + tasklet_schedule(&d->arch.paging.shadow.pv_l1tf_tasklet); } #endif From patchwork Tue Sep 21 07:17:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507341 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 94F17C433F5 for ; Tue, 21 Sep 2021 07:17:51 +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 44B08610E8 for ; Tue, 21 Sep 2021 07:17:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 44B08610E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191410.341427 (Exim 4.92) (envelope-from ) id 1mSa2B-0004Gd-2u; Tue, 21 Sep 2021 07:17:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191410.341427; Tue, 21 Sep 2021 07:17:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa2A-0004GW-WC; Tue, 21 Sep 2021 07:17:42 +0000 Received: by outflank-mailman (input) for mailman id 191410; Tue, 21 Sep 2021 07:17:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa29-0004GC-QM for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:17:41 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 325a3e8e-9eaf-40a0-a08c-a5a859c2f989; Tue, 21 Sep 2021 07:17:41 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-5-eChuMQnbM9OtR8qRh1PPBw-1; Tue, 21 Sep 2021 09:17:38 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB3293.eurprd04.prod.outlook.com (2603:10a6:802:11::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.18; Tue, 21 Sep 2021 07:17:38 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:17:37 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM0PR02CA0154.eurprd02.prod.outlook.com (2603:10a6:20b:28d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 07:17:37 +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: 325a3e8e-9eaf-40a0-a08c-a5a859c2f989 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Le5BJdNW9ne/Xmuzk0IFXev47snchE6r7a8FNfwFXaI=; b=A9l1GU7mXI5buJf81fafDwrA5TGWj8njefwNhc8hQlqQAx+o8dGt+TreZYsXJvk2H1+3TP F3t3i6i870w+0pTqSpCQNYCkcS9UClGqfbt4vnRT9fh21jtYoI+8jrBeK+sS6iqqdJDtou 5vxy44IXrhqODou+c97BLSCUIV5qSE8= X-MC-Unique: eChuMQnbM9OtR8qRh1PPBw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cnlVwtVClkmwJ1yacAro2yUcn1YX3AJVFXaPTI3uISPRttF5md3bt4bzgLbfdHxlYn0ru8z6CbFbRyN+XBab0h5J4/vQx/REo4UeeOHOJdCcv5/cpASccUUFK6U8Exe3Q4Qn1Xa+BB5F/PB36dsy2ZypYZbDUePYmFC/tpK/7leFlDE/UIsYGew0392kRqXxZnjuNCDpnc6jO28SSJW3b58iZB2OlLKXYRs2ZnpKVYQxJ5PyPUzs6MfBoJxGQGGxcZHhV0px0wEZ9BzimigxlI6IVeyPqhoEWA2JimjO/j61F7zFcTM6ZS1vf6h1QqbnblSHmKfGbBQdNlbmzR0clA== 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; bh=Le5BJdNW9ne/Xmuzk0IFXev47snchE6r7a8FNfwFXaI=; b=nd1gnSPL/TPVYL3hiOj9OPt6AS2yi4U1Jk75RsVCfkJuFKdkFFMobWI7k70J/bpR7tGWHnDF48QZe8BVAS0XZ3XtWuBucPVCnwuV8BcZp0m6KGRdqKiP2SsgcDoYY0ar5NM16HAWELPt1hIDsRbqXf+6TNn2SdlWuocZa61xnjr3RNs7ITXvlU/UdilnZTTmiKdR7Spzl4U3aoTXTNeL4sf8UtOzApvnQlux/9CeizTdCf64OPWaghof0bo9bp7Gox0+SjOc5BG+de55y0czOzY9d2iifv4wmSLMlwq1c0Ap3+7HAOvtv1xqfuRZYaqSrh4Kxs7YJb61+HsiIqvAQw== 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 Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 3/9] x86/PVH: permit more physdevop-s to be used by Dom0 From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Message-ID: <78c84053-3d79-b36d-be03-08b3b3a3d26c@suse.com> Date: Tue, 21 Sep 2021 09:17:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: AM0PR02CA0154.eurprd02.prod.outlook.com (2603:10a6:20b:28d::21) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 97c6805a-0f31-471f-e4ea-08d97ccfe42c X-MS-TrafficTypeDiagnostic: VI1PR04MB3293: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sJ9tMjWXdmprCrWK98SbUGnUwiMblG0eEeciQSt6Dk0DTN056yNhOWYk0U5l//h/q6Nict1ck6qW1ml0QtbChX0wZxE5nmbZwDDHI1LAfqlZZguq5xMwNutb1iA0xC9/mjHxd+ctRiAlvAZMmgXMRdjuUxXaKvr56Qgl+7D7Cy+41zPHA+xvYmjk7soyNDKIaq0s0KmPd6twrqVhNl3kI1GFLfkynR2rCRFzTlBgb9kLwqD3JNVvwsgKr/WFSLY4lQPY0x/T7v17kS2lUVFVtLCbrNImIzhDC2H9hgu50lpXVsyS9dAPCSN1jwJ6fpNloeG0Iu2oo9aTHHLd5x6rRiMN8EzGcawO54rw1WREmYXvUm0w5e9UuSO3zmNVDnk6X85EivlSoTw9HQApWGx/lBS4DuoJb+YtNun46ZDIAPNpQazpbwQNkj8yaynZCVK5kBDqPwqR1ucKC28mdDf7zqQ4O9c6pEsNwpOK9AjgqaYFcAoS+hAvLqaiKAULSbBKQ52GqbyLZJoA+fpcxC4iERHm4BmiqyvRbVO8QT2BsjYblY7bNeoZf0D07hWKS8OOpGAo48WwVgc9Jg557VrbCtwRh3jwOP7U34esEpP0+nUuIYMr4jXuDk5z1WT/hkV2ahjh5IPZUd5M8vTZYwIplUh5Q+ZcKuXZuDvz/O9U7uHXxf0mEAEvHAC6Cp60LE/TIfB4i/Frqephz097CDmEQPNnTIsYreK2FUl2damey+U= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(16576012)(316002)(83380400001)(31696002)(8936002)(956004)(36756003)(2906002)(86362001)(54906003)(31686004)(6486002)(508600001)(66946007)(2616005)(26005)(4326008)(38100700002)(8676002)(66556008)(66476007)(186003)(6916009)(5660300002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?enEXotrXYg75V1DkYWiLLuDu9BDc?= =?utf-8?q?a4p1aEKJ1lmNFT8xTS85jvtC7/o/p/M1IRIrVHjcpxb6eFbktFte0daUY6WjhP8M2?= =?utf-8?q?KQWftgYteWLEjTDmNRQqk6JlUcw6eDP+5Vs6paTd/Two5jEXsJP3cRnQr64rehaqW?= =?utf-8?q?rn/lv4FrVSnrJw8I+/MQj23ilNEfmhjlyLo5FhcLcPh9qWMDDRBCwDuj5Q6soi0Da?= =?utf-8?q?thpH3E4iOtPLXD83zFrbTCCUBJpmlp+VUryeDXANNx6TZfR3By6JKtk7spybnSZ4n?= =?utf-8?q?mbwZNYjXrOfff//X/fqFEB843caKt9Gp0bDOcYrMYIGCwKU43T0ca6jhZvpUQ5dYz?= =?utf-8?q?83iKpnCoqurChD0D2dW4+3xXOAp7N3eu1415WwIRtInTVbCHv/xkzBmMmzxSFNDuy?= =?utf-8?q?pQVAI4M5TXxwKZZEbdt6tQyLPrMJqhVgQKc+Ll8cJa1YrzsbkwgR2fzQvgeDmWOD1?= =?utf-8?q?A/7H/O4P8ZmNz/JW7AUae14/UHo6xudpf21aJq7yYZYGgs1CDAnlmsdvlmsDF9KES?= =?utf-8?q?YKxriHCqzYOmttCVatlla3lWibm0KeFYUIeNnZf6j9Lge+NJavMhef7d+iEpu6DsG?= =?utf-8?q?2rui5bVs5RlVANXqUMJge0g6MDfYnql2eFEdGil5fGUgBMo5bH4eU2zNzUDcgsYkY?= =?utf-8?q?aGD0i3Ov22R3HdR0J/SKyW5r76K+4TU4s4r5W33MoZ4hIPPxVCDsR/qCpvglvBgO5?= =?utf-8?q?5bC1fR9Kxs2fOcXr1M2cciOQyffWxadghR3GfHUGp8Sjj0cpS37/Lu5MaywzYmdfB?= =?utf-8?q?WXbQ0GU+ccU1FZFmneQUCXywB5Nsph7zVylhyMSEYWq4pNutxaGgNzIIqOiPvUR9l?= =?utf-8?q?UH9YeagKEdc2LzO0TijyYV7ZsQCu1mZ1FfFwg+6nbYfwiPg1a6FU0Cl77ljLXdSFI?= =?utf-8?q?DOravq7W3XAvXCkeqC8issFJ8xGHa9AlWAkPgMzoJ0O1CXdpAiNQdj6ajmrjWl8ax?= =?utf-8?q?mE8oOfEQw58vf5pQZjN1ep0vQ2qHKaVCfdascRZdShUB4l0/yIiedPfkRuboNswZF?= =?utf-8?q?t7r79FwqJ+IbA84hCzcbA4gJGw9RYy3t0qpJgVVJAx2I3g/stASH5NbDDVWLcq6kO?= =?utf-8?q?WyOQaN7pFOsr4dxTEODrDgLZzC7V/WD8Y1tWBowNOlsn1dxSSB2D4KNo37EfuzrqY?= =?utf-8?q?OzJHyjfM8MLHlX7wxohcqh7f5oFjOEzYgDfcMHUKyEC8Wle2BbsnwkzLMesP3bby+?= =?utf-8?q?ESpAx7kEqRHhzZCRu9pTzaCGkrtlOgJqfoKZRq9LGscOu8c3PLYnK9OEtkDsVLkMA?= =?utf-8?q?lwwFKBQJZ1MXIF5w?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97c6805a-0f31-471f-e4ea-08d97ccfe42c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:17:37.9216 (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: 1SOn0nmxyIpiNa4GGLBTPAAscpU9iU2OImNjof6+o3lAirSvzjUDaO4WZOudbiZwDYqLt+hU/W9DsdgJK/JxaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3293 Certain notifications of Dom0 to Xen are independent of the mode Dom0 is running in. Permit further PCI related ones (only their modern forms). Also include the USB2 debug port operation at this occasion. Signed-off-by: Jan Beulich --- I'm uncertain about the has_vpci() part of the check: I would think is_hardware_domain() is both sufficient and concise. Without vPCI a PVH Dom0 won't see any PCI devices in the first place (and hence would effectively be non-functioning). Dropping this would in particular make PHYSDEVOP_dbgp_op better fit in the mix. --- v3: New. --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -94,6 +94,12 @@ static long hvm_physdev_op(int cmd, XEN_ break; case PHYSDEVOP_pci_mmcfg_reserved: + case PHYSDEVOP_pci_device_add: + case PHYSDEVOP_pci_device_remove: + case PHYSDEVOP_restore_msi_ext: + case PHYSDEVOP_dbgp_op: + case PHYSDEVOP_prepare_msix: + case PHYSDEVOP_release_msix: if ( !has_vpci(currd) || !is_hardware_domain(currd) ) return -ENOSYS; break; From patchwork Tue Sep 21 07:18:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507343 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 2514BC433FE for ; Tue, 21 Sep 2021 07:18:22 +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 CBE8A610CA for ; Tue, 21 Sep 2021 07:18:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CBE8A610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191421.341438 (Exim 4.92) (envelope-from ) id 1mSa2e-0004yu-ET; Tue, 21 Sep 2021 07:18:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191421.341438; Tue, 21 Sep 2021 07:18:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa2e-0004yl-BE; Tue, 21 Sep 2021 07:18:12 +0000 Received: by outflank-mailman (input) for mailman id 191421; Tue, 21 Sep 2021 07:18:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa2c-0004y8-Fl for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:18:10 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.111.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c7599eb2-73d9-48c5-b499-691ebcd457a6; Tue, 21 Sep 2021 07:18:09 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-24-_46qPZCjNa6EFG6pHLvE1w-1; Tue, 21 Sep 2021 09:18:07 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB3293.eurprd04.prod.outlook.com (2603:10a6:802:11::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.18; Tue, 21 Sep 2021 07:18:06 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:18:06 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM0P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Tue, 21 Sep 2021 07:18:06 +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: c7599eb2-73d9-48c5-b499-691ebcd457a6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=52koP07e3NaHR5tP62Xc53aym67B0vZJLqdc3ZgaWY8=; b=RPd46UMZtmtMZ4jckRbW6fZf6vxV68eutVjz09cPyOPaZse1TdVVafVjfWQyPhL+Xm6hbT +YL3zAqUKp6mXkXXKiWtgrl1nSo/8fVuWXkAVdUQ61IuoSHo+85p7IagztGFVS7tUeaBSc PptyrfMpu2CDMETLS5LVtFXbXPkN58c= X-MC-Unique: _46qPZCjNa6EFG6pHLvE1w-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UbRThvdDBVayNVbt2MvjeYXE6UYWlef5lu8TZc1+dNew7bOh1UkT8SSjkVbYlK9XlCrkVYE5BofDBUxzA8pnvxRk/SYBvE3QOg4OF46ADy7IVv+Tx4eiZ0xG7HCRUpJ6om0xooIshtMNNJJZUNOZ22B46loPw93laOfb0PgV+t9Rf8nUFL1WCmnR8U7iamDw6mHdaIEOchD9hbLoYVBODhBo3nHalJiuUx0ow2GAfC3uCJTxD5EBJN/4gnL2AfEniJ/f88w58qi9TyWKY1BPZpfPJKf/JUY7C+3eEtvxbsmAQqQrSGYW7hzBJLHGqhZwVCq4CR11/Y/g/5O5G1X9eA== 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; bh=52koP07e3NaHR5tP62Xc53aym67B0vZJLqdc3ZgaWY8=; b=RvAM4xaN7snbVlZnp8LCn9br8VBxGwnzEGaZkyLLQsNqHk3lutxVSK1Jpif64ApGcsO0dfuqiZnsNtXseOmTlOocgo+2CZKAjq3bwBT1j8gUsmOHA7q127kD0vXWvtmem7GFDql3Sputr4XYts2ijciGyv2wDRGPGquHV22388Htsl3uaa13qHtXl2rzvFj+tkI52J1Ed26fnpVvLVy6jBNUbcpMHJBxd7xMqzUFCJHSnKFS7DmDBA9SDXfndqVJaz3NAboJlVdDLC3mU9cUcysaMS76ohEV83Ppp8/uJ75MHxJnVLnss5WMzy3cHxCelb9C9vDircJawsNQsnZXRg== 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 Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 4/9] x86/PVH: provide VGA console info to Dom0 From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Message-ID: <215e2ea4-cb49-7d94-7f97-c6b81e522a60@suse.com> Date: Tue, 21 Sep 2021 09:18:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: AM0P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::39) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc55bae7-f929-421c-52d3-08d97ccff532 X-MS-TrafficTypeDiagnostic: VI1PR04MB3293: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 82q5LXkChGB0DZawfOcqS7gbPxNFrD2ouq7+J/Xv+MiqcYUBMpOABgLxl+WQSGwHwG+n38WVrtiQOxG8lAdycMO96kpjbbSgCQufz0b+9DjFfe5vMF7VjMytFse22FTHzgdD++zNVRTcNlziIxuxS04LCVfdDIzmA4shboTvBAinlktxNY+45iqxuRlmLGdbZhcCOxMdWmgigH/pPm+5T8cJ6O9xJ0hVnRqprle2BQpilqFpj7jFkPank3GW/U7qPdBYy0+iLflLCTfweV6id05CI29VB5tB9jSyPMBEKiFXF0Wygbml5dlBlRyASR8ZdEV6UMlNQZb+LMBMtnd/Ha4oGbxl3s86CGIRFdeNfsIa3repJ8cQ0vTqyIHpJSJMaX49cl9MrsaTv9gnHixD+JNyprT3iFSMBpJhBVIRu0GHi72BPPWF8fnZrT4HAHEd78wILyCqZ+trDkbo+rE3RFoG74iVkbPFoDafep8d5ED3mEd0i0Tun8bcjF4II4BvkHZ0EUmv19vNfE4IYtY1D26abXH4Lx7HaINLxRUkUke6c5bcWfgNEtpWlpFXqZ4TEjYQgVk6qMU5gnCjnxDEdjve1RdaZork2zUd4pxzvN8QmBAF9BOsRW5EI4mYC2FZ63wdX0J22bJSwYZPJ2JsQTX48cpx/uuSH/XrA/akz6rxCi15l6lnMqThQ9ZaVs5WpJyK4pXsmUn2URRdT4k70mvoF6r8iybUjPnV/Je1VOq8sCo8RXOxlU3z1TvJpXCO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(16576012)(316002)(83380400001)(31696002)(8936002)(956004)(36756003)(2906002)(86362001)(54906003)(31686004)(6486002)(508600001)(66946007)(2616005)(26005)(4326008)(38100700002)(8676002)(66556008)(66476007)(186003)(6916009)(5660300002)(21314003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mUnPLdBc24WhGRI55qp67bq4P9e8?= =?utf-8?q?KPW17X45SIdIcEX909Vvcu8Vgjv+b2Yn6omewNvFMN4dJG9LiU2SWHcIiXxMhduUw?= =?utf-8?q?L10LOee5aZlFTAfUy3aWaa3jVxh6CtxBrbwMBvJgBlkw9CQosY3iaVCPeG1riH1Iu?= =?utf-8?q?8/aQH0P/pK/qfML6jT1YawKI/JFNfjniNBJ37+9A2Cqy68F1uwquq5UKrnL8C14yo?= =?utf-8?q?Tdv2Nn8xOIbgaBfHm6FaTE3b3jrE49mtzPvSFg9n0rO4xVo1P+QgU1ekSTl+B5pwl?= =?utf-8?q?ehZSB6/SH5XhlrZXVX2SUzvnR8wfgDkq744L0KUxlfrYv+rFTUq6mEWwKlxKownsu?= =?utf-8?q?HAT3OXI+ejnxhyQZTOXnNnfeBzh+tK42i5T2GthERUtgEUfvV/hJyJj63/9wCcmhF?= =?utf-8?q?HQ/gdxNgSu68aI5oot01Iz7p/8eteaRqRbBKZIGriV1HfxQVSNotDZq+Gbt2ZVr3C?= =?utf-8?q?Nw9DfpT/yajy0CE79S+vPfZw3h1N4hFy9fENPov2WrLHX/VO8RUJAHJMJ1gXpILkq?= =?utf-8?q?Rq7kMhZqGAZoUDa54u3x0s879dJ6ZDMHIP5cn4mMLkxoCyOrf3rtEP8FmO4nDH+TK?= =?utf-8?q?P9NkIep8oNLiM5L4wVv+9frOvVTLJ2Oaz1OYBh6PIj1WxEGqRQVf+T8JBmqZTsJpV?= =?utf-8?q?oelSh9a8Q/DvlS8m0CC70mS3fdxdRP1Qi2HjBO1/t+GNOAr4Gw2cUZkQsnhPJ6IOi?= =?utf-8?q?1YiEDUE/5AoinDPu4A2SVNjWEHtWdur9R6jNGEo4ix9/cGyR/FO2wnoJp2+REblAY?= =?utf-8?q?l+7yYKnzaOE+v5W6ivy5djaBhFKjYNP2CuzFjfBx+Yxw2ESVIyhuug9rI43NfMu5a?= =?utf-8?q?+R0Ph0u0EbcC7M51Ay2mGT+mpTMG4Im/vfVJKYRE/g/6Lmdb6W1sIzNbBm50VtMoU?= =?utf-8?q?yNIv9Ka2JfOlKym9vODCo9a+0xiu4akdo9RfclxxuTa54z+NY+2BboY0ANVvOl3lD?= =?utf-8?q?pUPw2XnKSKVbRUSFwtm/NZn16VgCa2Fh+amuq64G0Bi4D2FS5ZTdI0fuFY4aGZD8R?= =?utf-8?q?vt0iWrZmARCZJ82XgYFj3rr4S/wMOlNw99v7fEmwNYJGBtFLcPgZZmTs6XInMktLn?= =?utf-8?q?2pRYd7ackNWX6nY5dmlPJwLffQBcYwgjwHCXE0wqIzDmDrGPsuk+y8KOY2szY2e/V?= =?utf-8?q?fHWeVYMaiEStjLLqklBP1dyVZxouz7tNNGKgk5T1KfF9GuyoxOdzBLSZOKwb7kikr?= =?utf-8?q?/dxzjpZ1PkfK1QHR1Yp1+ePOGWdvY2JOXRLLpUotO1ZyFouIQ+G7Y0BCKrvZGbRu6?= =?utf-8?q?5TloD5Xl9Qom198M?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc55bae7-f929-421c-52d3-08d97ccff532 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:18:06.4805 (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: Obme7KzxnDdnISlUP0hQRyt6iuxFFL+Ica5tJ9PqiaE9bpD5/ev5GvEcGKpJaXf74BYAuVrH/66574w6xM3WDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3293 Like PV Dom0 in order to use the console if in a mode other than text 80x25 the kernel needs to be provided information about this mode. Bump HVM start info's "current" version to 2 and use a previously reserved 32-bit field to provide struct dom0_vga_console_info's position and size. Signed-off-by: Jan Beulich --- v3: New. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -19,6 +19,7 @@ */ #include +#include #include #include #include @@ -549,6 +550,11 @@ static int __init pvh_load_kernel(struct paddr_t last_addr; struct hvm_start_info start_info = { 0 }; struct hvm_modlist_entry mod = { 0 }; +#ifdef CONFIG_VIDEO + struct dom0_vga_console_info vga_info = { 0 }; +#else + struct {} __maybe_unused vga_info; +#endif struct vcpu *v = d->vcpu[0]; int rc; @@ -598,7 +604,7 @@ static int __init pvh_load_kernel(struct * split into smaller allocations, done as a single region in order to * simplify it. */ - last_addr = find_memory(d, &elf, sizeof(start_info) + + last_addr = find_memory(d, &elf, sizeof(start_info) + sizeof(vga_info) + (initrd ? ROUNDUP(initrd->mod_end, PAGE_SIZE) + sizeof(mod) : 0) + @@ -672,6 +678,22 @@ static int __init pvh_load_kernel(struct last_addr += sizeof(mod); } +#ifdef CONFIG_VIDEO + if ( fill_console_start_info(&vga_info) ) + { + rc = hvm_copy_to_guest_phys(last_addr + sizeof(start_info), + &vga_info, sizeof(vga_info), v); + if ( !rc ) + { + start_info.version = 2; + start_info.vga_info.offset = sizeof(start_info); + start_info.vga_info.size = sizeof(vga_info); + } + else + printk("Unable to copy VGA info to guest\n"); + } +#endif + start_info.magic = XEN_HVM_START_MAGIC_VALUE; start_info.flags = SIF_PRIVILEGED | SIF_INITDOMAIN; rc = hvm_copy_to_guest_phys(last_addr, &start_info, sizeof(start_info), v); --- a/xen/include/public/arch-x86/hvm/start_info.h +++ b/xen/include/public/arch-x86/hvm/start_info.h @@ -33,7 +33,7 @@ * | magic | Contains the magic value XEN_HVM_START_MAGIC_VALUE * | | ("xEn3" with the 0x80 bit of the "E" set). * 4 +----------------+ - * | version | Version of this structure. Current version is 1. New + * | version | Version of this structure. Current version is 2. New * | | versions are guaranteed to be backwards-compatible. * 8 +----------------+ * | flags | SIF_xxx flags. @@ -55,7 +55,15 @@ * | | if there is no memory map being provided. Only * | | present in version 1 and newer of the structure. * 52 +----------------+ - * | reserved | Version 1 and newer only. + * | vga_info.offset| Offset of struct dom0_vga_console_info from base of + * | | struct hvm_start_info. Optional and only present in + * | | version 2 and newer of the structure when + * | | SIF_INITDOMAIN is set; zero if absent. + * 54 +----------------+ + * | vga_info.size | Size of present parts of struct dom0_vga_console_info. + * | | Optional and only present in version 2 and newer of + * | | the structure when SIF_INITDOMAIN is set; zero if + * | | absent. * 56 +----------------+ * * The layout of each entry in the module structure is the following: @@ -139,7 +147,15 @@ struct hvm_start_info { uint32_t memmap_entries; /* Number of entries in the memmap table. */ /* Value will be zero if there is no memory */ /* map being provided. */ - uint32_t reserved; /* Must be zero. */ + /* + * The following sub-structure is only present in version 2 and newer + * when SIF_INITDOMAIN is set. It is reserved in version 1 or when + * SIF_INITDOMAIN is clear, and absent in version 0. + */ + struct { /* Coord-s of struct dom0_vga_console_info. */ + uint16_t offset; /* ... from base of struct hvm_start_info. */ + uint16_t size; /* ... of present parts of the struct. */ + } vga_info; }; struct hvm_modlist_entry { From patchwork Tue Sep 21 07:19:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507351 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 8224DC433F5 for ; Tue, 21 Sep 2021 07:19:23 +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 2AAF9610CA for ; Tue, 21 Sep 2021 07:19:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2AAF9610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191428.341449 (Exim 4.92) (envelope-from ) id 1mSa3e-0005hB-Oo; Tue, 21 Sep 2021 07:19:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191428.341449; Tue, 21 Sep 2021 07:19:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa3e-0005h4-LT; Tue, 21 Sep 2021 07:19:14 +0000 Received: by outflank-mailman (input) for mailman id 191428; Tue, 21 Sep 2021 07:19:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa3c-0005gl-QK for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:19:12 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3ee276b3-60c2-434f-88e2-2188a7c33695; Tue, 21 Sep 2021 07:19:11 +0000 (UTC) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2055.outbound.protection.outlook.com [104.47.9.55]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-19-IqfAnf8hMJiXfa4CvRlazA-1; Tue, 21 Sep 2021 09:19:09 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4190.eurprd04.prod.outlook.com (2603:10a6:803:4b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.15; Tue, 21 Sep 2021 07:19:07 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:19:07 +0000 Received: from [10.156.60.236] (37.24.206.209) by FR3P281CA0056.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.5 via Frontend Transport; Tue, 21 Sep 2021 07:19:07 +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: 3ee276b3-60c2-434f-88e2-2188a7c33695 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kOHPUdSszd1R6FGaIvuWyobel0/L1w9ZbdVwz40lrjw=; b=Pj8RS6sueAeoZuysgJQ6xuwCOBzOoGmloV3D4sfJPAdkxhiRULGGlN0+lfJqf90B7x2ppm 1gWrlF9bhBH7pvL72bxq7orDFQqSC4SAUmrRgOlqnPjXUwI+wf5/oZ9NqCPNWdQBmrQfDf KkMOOMUTRSgcLOB+IGvvG9NWNx8OR2A= X-MC-Unique: IqfAnf8hMJiXfa4CvRlazA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YQsC5t1qnE4ToYU8KWXjKGb6ULOHbYu1/J4LvakQPdtBR3ecLi09fMTFwp+cVCRhJ6fefLvhoONDwIdaUJhSKX4mcrFgf7Vu06hO5XPTCrhCoAf/4bLcI9iB/DgBdPd+tHd4YBTSqtaKIJd1uC37kvnj0itfGj5WaTSsfat4xdhNacUCc4M62DQA9w9gpgI+ju8KRQJwgEfWU97lYe2aYy2g6BURSwxXfU3nyk5DPsaz1j8woHIFkETEkHCL0fEoR4RH1fbydU35EUfoyitAEGITXgVToHsRp14kDattxHfb5qyAqhoAp7/vOirm+ANafJRTDW8lKqe2l7aaefrT3Q== 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; bh=kOHPUdSszd1R6FGaIvuWyobel0/L1w9ZbdVwz40lrjw=; b=BeUyHrsCvxNJVgi5tRdNxILXpJChThXQX55vbv4socxfSiALYJT+g9OMflrxdzHTuKh4OAAs9MwILSK/FXMIW2J6C3aoPvxdi777040g9nJm9fPWR5IHgauQA7ci1bnD5qk44L3T8dZgmauyvjm2y0SQ6u7uGamPi0uxacnDF23FqoyMjOle1dOkYgOz2qa/H43uFBTv/Lg2dzckGpYOHrmtjK4WItltjvxZQaKnloaQ/FxERzQLHOUbwX3u140R58Ofu1PX2u1QXqo3Yta/dx+LqPcn4HYt5f0vy0EWu1Crhy65TGP4+Y8rZ9Z2FI/VfP6gR2v39QGQTyV7WugzvQ== 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 Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 5/9] x86/PVH: actually show Dom0's register state from debug key '0' From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Message-ID: <4ae1a7ef-d6e8-75db-ddf5-987f10175196@suse.com> Date: Tue, 21 Sep 2021 09:19:06 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: FR3P281CA0056.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::6) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 28c134b1-4b59-425d-1804-08d97cd01987 X-MS-TrafficTypeDiagnostic: VI1PR04MB4190: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cn1h9ducNgRNq3NeT/9DLNgN8VLEtbmdddDU+eS84S5DQ26p7/kO2uoaUH1X84odJ1L81H4cgJrGK6xKIUYOkyuE5yctANU93ulOc/YCxcAcnht6l9uX0wAnlYSmi+teyekYE7UoImlLhCLoZJRbHZKtmLy87AlqlxKitdJRzH2TA2vQ8TfgKRdRwqfUZFFL1c2djsBq1rmREc+uv43i/Ez17R4NJ8uRFe0pM2rKfIChtBBlJ2KJHQHtQHj3CS1S6HgXBPXdKaHUWlIq4anQLS95X+Am+qPPMMIPhHF4cjrr0wUDWykYeNiMRDA3VyxT1K6d/3FbnAldNxnbASXj4G0pOHvWU3eOQ0HDwWK7qqEDUE0TuTquQu3S27XEi2vItmgm9mcfOBSCxYGqTzLXozPMzfu4cMFGkRpMihlHOOKxugXor5Ore8zI0lN+8bp++1Bab+5ai1XODvulZHnX8gOQlDAQGlrAppFfM1URhoyKENsl50wXudPlN0rh9efrA2VLWv6ItcOIP4qLOfT7JTIhVQJvNnnsARi8hgUs5+GQ5FG4H9iibVfJtuftaePafdL+8afDLL0GtSJXICqkNnLtl0huBDhVbzxjU7oCPwSmnpfworPKBksx/2ha3+0COTdkDt+xfdfdb+q908bjWchd0bC9dJiIVTnBR33Ws4FfLO03jxc6pvIG1Q1p0rcvTe5xD3ebDECgCsUD0q3BWQHnTA3Vj9oGVI5O0fEAt7E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(2906002)(26005)(8676002)(186003)(36756003)(86362001)(66946007)(66476007)(16576012)(6486002)(66556008)(38100700002)(8936002)(5660300002)(508600001)(956004)(31696002)(31686004)(4326008)(54906003)(83380400001)(2616005)(316002)(6916009)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yYBftr1Zu68cM/QpsK/pO9mZDXFw?= =?utf-8?q?R5lRV9/LRZrbhK9E0GPCrKweLH3S1Vg0QfzGcjaNkPf0abQqdjmcuV99d1/j36y5Y?= =?utf-8?q?E6g8v5dPfzSIJJAfMAOi9p1EFkRCurF6hntckfiME1cnyh1LmAs0ZthaPIdI8E00T?= =?utf-8?q?d/B4fk1zorZOmOdx437JZ4ot4XfULNpQ4dkGPXxcvufP+m1jjkaiNlZqF/N7rnzPM?= =?utf-8?q?9E8jyGrGRyj7junhGS6OLZ3XIvCoz8TUkQSZEA4ypJUkYa2AcntGqclUnpUUnVrIE?= =?utf-8?q?IeVpxiMGMfZa8Q5gg3/hTj472mgHU+FhpxGJXLefmGp1ZI0cZUEYAc3T4sPBWD2JW?= =?utf-8?q?fI3TuYxGStJMD6WDwXamFiyOgyT9qQXyes4IhpaQdxpkJeeRFDIrGM1D2X4CwMCSR?= =?utf-8?q?Zg3KcSxLUd1J2q4DRIZApeK+R/yIazXoZkzsk2WsFvo6bmJ3h/7CJGAwH+hjz8rQ2?= =?utf-8?q?eVQeWlf/dinyYmaGMytVGz4lsyBENzEvpAsOw6CRrJQYCPtnIN74PbxcK1Mo7LeqH?= =?utf-8?q?SV7rzEm8xPFs5zu55Pfj2ryWyZheTZxuBkwED+J9WDRI+DG3Xm8kjroAwnKT7luRG?= =?utf-8?q?wABYLHWelsLyp82KFOZs/8zV3tkwIqs6fOKHFtjWKfWh5fOPqbfkBt19xE4LBhtAH?= =?utf-8?q?oigXscZIS7Qkf37KpeueqR/L/vvrJ2KGN3ILdYTGK4/KkoJb17DfwqvJfCV6zPn0S?= =?utf-8?q?DIsSh1S3QF5KQ5DCf+GBV9nCWnmCB7R0G9URHM6J1IpZ/hOBbuS6tEwSJacA/TuzC?= =?utf-8?q?3uDUkN0GzVW7iCpicLUTbbHj+BdyKyLeNB6SgKVNk40bFPvCQkFjySnDuzcfkyAEI?= =?utf-8?q?RQ2cImbe99AqT7segp9/s+3l17HwHkKwTo06y1RHhbc2AdKQJTTqDawf4sLzQ6uwv?= =?utf-8?q?DTEeMtTWiaRhdXP0A+aLQprkxdQsVl7qdaqVNuTC72UXvnxFACnwd44tW6yaP2Nqo?= =?utf-8?q?KexhKd+V1fMYLYtuBUaUrm0yGLl8iGjU1jhyW08B3V1mNehAj14FiU2JeODQTqGOl?= =?utf-8?q?OpIS65rsZvjAFwa5jC+WZ5ipOL2zcqwSsZg6Mltr52y83AZizhbcIzEjhFFBQmiUI?= =?utf-8?q?JfoB99mlgHY0G8O+psHIsobltW8iW00Hd6KjRUsgRPahW3dRcyrvMW8LwhTARyBFf?= =?utf-8?q?+v+qK/TaM792oxdNpVnveZl1HTqZByrIbJDN0Sno/Pbkgv+piSNg9e7tYxwX5X8rq?= =?utf-8?q?Pw6Wo2roKdT1p/ENJaH8o5brjXRvzpKbUSsNzZ+yy0RAJM8uteG/mLXMwPWgliTZL?= =?utf-8?q?TIAgD4SOdU7Kdysj?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28c134b1-4b59-425d-1804-08d97cd01987 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:19:07.4200 (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: niCjkYQ3aKdW4oQpO0dESCxLK60zKsFooAqyUCZwDg61+IXks1lCXKIik02e1cZNs3sEyTy/QCzeLTBe5gyLcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4190 vcpu_show_registers() didn't do anything for HVM so far. Note though that some extra hackery is needed for VMX - see the code comment. Note further that the show_guest_stack() invocation is left alone here: While strictly speaking guest_kernel_mode() should be predicated by a PV / !HVM check, show_guest_stack() itself will bail immediately for HVM. While there and despite not being PVH-specific, take the opportunity and filter offline vCPU-s: There's not really any register state associated with them, so avoid spamming the log with useless information while still leaving an indication of the fact. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné --- I was pondering whether to also have the VMCS/VMCB dumped for every vCPU, to present full state. The downside is that for larger systems this would be a lot of output. --- v2: New. --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -631,6 +631,12 @@ void vcpu_show_execution_state(struct vc { unsigned long flags; + if ( test_bit(_VPF_down, &v->pause_flags) ) + { + printk("*** %pv is offline ***\n", v); + return; + } + printk("*** Dumping Dom%d vcpu#%d state: ***\n", v->domain->domain_id, v->vcpu_id); @@ -642,6 +648,21 @@ void vcpu_show_execution_state(struct vc vcpu_pause(v); /* acceptably dangerous */ +#ifdef CONFIG_HVM + /* + * For VMX special care is needed: Reading some of the register state will + * require VMCS accesses. Engaging foreign VMCSes involves acquiring of a + * lock, which check_lock() would object to when done from an IRQs-disabled + * region. Despite this being a layering violation, engage the VMCS right + * here. This then also avoids doing so several times in close succession. + */ + if ( cpu_has_vmx && is_hvm_vcpu(v) ) + { + ASSERT(!in_irq()); + vmx_vmcs_enter(v); + } +#endif + /* Prevent interleaving of output. */ flags = console_lock_recursive_irqsave(); @@ -651,6 +672,11 @@ void vcpu_show_execution_state(struct vc console_unlock_recursive_irqrestore(flags); +#ifdef CONFIG_HVM + if ( cpu_has_vmx && is_hvm_vcpu(v) ) + vmx_vmcs_exit(v); +#endif + vcpu_unpause(v); } --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -49,6 +49,39 @@ static void read_registers(struct cpu_us crs[7] = read_gs_shadow(); } +static void get_hvm_registers(struct vcpu *v, struct cpu_user_regs *regs, + unsigned long crs[8]) +{ + struct segment_register sreg; + + crs[0] = v->arch.hvm.guest_cr[0]; + crs[2] = v->arch.hvm.guest_cr[2]; + crs[3] = v->arch.hvm.guest_cr[3]; + crs[4] = v->arch.hvm.guest_cr[4]; + + hvm_get_segment_register(v, x86_seg_cs, &sreg); + regs->cs = sreg.sel; + + hvm_get_segment_register(v, x86_seg_ds, &sreg); + regs->ds = sreg.sel; + + hvm_get_segment_register(v, x86_seg_es, &sreg); + regs->es = sreg.sel; + + hvm_get_segment_register(v, x86_seg_fs, &sreg); + regs->fs = sreg.sel; + crs[5] = sreg.base; + + hvm_get_segment_register(v, x86_seg_gs, &sreg); + regs->gs = sreg.sel; + crs[6] = sreg.base; + + hvm_get_segment_register(v, x86_seg_ss, &sreg); + regs->ss = sreg.sel; + + crs[7] = hvm_get_shadow_gs_base(v); +} + static void _show_registers( const struct cpu_user_regs *regs, unsigned long crs[8], enum context context, const struct vcpu *v) @@ -99,27 +132,8 @@ void show_registers(const struct cpu_use if ( guest_mode(regs) && is_hvm_vcpu(v) ) { - struct segment_register sreg; + get_hvm_registers(v, &fault_regs, fault_crs); context = CTXT_hvm_guest; - fault_crs[0] = v->arch.hvm.guest_cr[0]; - fault_crs[2] = v->arch.hvm.guest_cr[2]; - fault_crs[3] = v->arch.hvm.guest_cr[3]; - fault_crs[4] = v->arch.hvm.guest_cr[4]; - hvm_get_segment_register(v, x86_seg_cs, &sreg); - fault_regs.cs = sreg.sel; - hvm_get_segment_register(v, x86_seg_ds, &sreg); - fault_regs.ds = sreg.sel; - hvm_get_segment_register(v, x86_seg_es, &sreg); - fault_regs.es = sreg.sel; - hvm_get_segment_register(v, x86_seg_fs, &sreg); - fault_regs.fs = sreg.sel; - fault_crs[5] = sreg.base; - hvm_get_segment_register(v, x86_seg_gs, &sreg); - fault_regs.gs = sreg.sel; - fault_crs[6] = sreg.base; - hvm_get_segment_register(v, x86_seg_ss, &sreg); - fault_regs.ss = sreg.sel; - fault_crs[7] = hvm_get_shadow_gs_base(v); } else { @@ -159,24 +173,35 @@ void show_registers(const struct cpu_use void vcpu_show_registers(const struct vcpu *v) { const struct cpu_user_regs *regs = &v->arch.user_regs; - bool kernel = guest_kernel_mode(v, regs); + struct cpu_user_regs aux_regs; + enum context context; unsigned long crs[8]; - /* Only handle PV guests for now */ - if ( !is_pv_vcpu(v) ) - return; - - crs[0] = v->arch.pv.ctrlreg[0]; - crs[2] = arch_get_cr2(v); - crs[3] = pagetable_get_paddr(kernel ? - v->arch.guest_table : - v->arch.guest_table_user); - crs[4] = v->arch.pv.ctrlreg[4]; - crs[5] = v->arch.pv.fs_base; - crs[6 + !kernel] = v->arch.pv.gs_base_kernel; - crs[7 - !kernel] = v->arch.pv.gs_base_user; + if ( is_hvm_vcpu(v) ) + { + aux_regs = *regs; + get_hvm_registers(v->domain->vcpu[v->vcpu_id], &aux_regs, crs); + regs = &aux_regs; + context = CTXT_hvm_guest; + } + else + { + bool kernel = guest_kernel_mode(v, regs); + + crs[0] = v->arch.pv.ctrlreg[0]; + crs[2] = arch_get_cr2(v); + crs[3] = pagetable_get_paddr(kernel ? + v->arch.guest_table : + v->arch.guest_table_user); + crs[4] = v->arch.pv.ctrlreg[4]; + crs[5] = v->arch.pv.fs_base; + crs[6 + !kernel] = v->arch.pv.gs_base_kernel; + crs[7 - !kernel] = v->arch.pv.gs_base_user; + + context = CTXT_pv_guest; + } - _show_registers(regs, crs, CTXT_pv_guest, v); + _show_registers(regs, crs, context, v); } void show_page_walk(unsigned long addr) From patchwork Tue Sep 21 07:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507353 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 4E61AC433EF for ; Tue, 21 Sep 2021 07:19:52 +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 01258610CA for ; Tue, 21 Sep 2021 07:19:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 01258610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191432.341460 (Exim 4.92) (envelope-from ) id 1mSa48-0006GY-25; Tue, 21 Sep 2021 07:19:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191432.341460; Tue, 21 Sep 2021 07:19:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa47-0006GP-Ux; Tue, 21 Sep 2021 07:19:43 +0000 Received: by outflank-mailman (input) for mailman id 191432; Tue, 21 Sep 2021 07:19:43 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa47-0006G8-3S for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:19:43 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.111.102]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 49b1ca9e-1aac-11ec-b89f-12813bfff9fa; Tue, 21 Sep 2021 07:19:42 +0000 (UTC) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01lp2054.outbound.protection.outlook.com [104.47.2.54]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-8-o06BvGRINnOqe1Or22CsTQ-1; Tue, 21 Sep 2021 09:19:40 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR0401MB2606.eurprd04.prod.outlook.com (2603:10a6:800:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.18; Tue, 21 Sep 2021 07:19:38 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:19:38 +0000 Received: from [10.156.60.236] (37.24.206.209) by FR3P281CA0064.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.6 via Frontend Transport; Tue, 21 Sep 2021 07:19:37 +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: 49b1ca9e-1aac-11ec-b89f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R/fFnczmCtwlapERXxOX/XNhHEnAVEjvjTgMNNwr6tw=; b=d8hxIQ3+Zjs9V0ufk1WdwDW13lp3CSuRyeVi4v+7Sfe9SAbtz71Q4LHm2KdBh7NeWTTVAy ocevN2A6/LvLA3GTPj1+BaBGK7no2a5ZEZEW1KdOiT9BaxNoU+6e2nKMgkBfvO4uVk4AZS hqPSBnCB2C2yWymoGYgKs5GjGbdd0gM= X-MC-Unique: o06BvGRINnOqe1Or22CsTQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vw0PD9v0hk/jRxeWzor461xYslltKuCVvmUzNIEgkwGAaEWQuQYTd+zjflwge69YRjZSPzPqfTArWCLE09YZyF+Sjt6v0MR0ukdPQ5Jjj7WEDgd5kXG6qrndCg6Riotfhrc/ZMkcLg50XC0hphVwC7VUPJrp2MtB1/vaU5BEl5XhphwBP+GVFz2EIl8iaKboeOdU62HvFfij8Z+toX49ovF8YQpo6ZPLMkUcx44Nn/NqIvSSsc8y/gHj9iqhPoQJhL2fHpWsBCSZaYS15AYzVcOpEuSduNRmLz8mqm2Lfqmfx4ZOBfgjBsf2Rd19I/LXR1T1dsp+dYjIZVBoaFt6ow== 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; bh=R/fFnczmCtwlapERXxOX/XNhHEnAVEjvjTgMNNwr6tw=; b=PScBIewm7KpmAyqZSfiMHy9k2LWhGe6dIBpaXajAa4/yVbYp14spCbLbVuS2TDTUiAg5ZnvSOczCYhWjcT8MfYAaAxskKwg21ZC5I1bD02Oti5xfpAZTOyZKhAztCpHM8hlIlJFqYke87rGGPlM6s+XVP+JzVdXFOM4r4dut9HgHMlW+UWRTVZgBK1mfKlHmdj0NilGBwZ16hLlJ5RYlXlzwi2iFgFp9JatSrgsot+5sIWUhXW2IuyKvawJK7+HG9E103qOnFxfEc3loC6z1YrIwTTZo0sYRRi1VK3ZeC9GKTw/AOl4jfRGKvaIVgP1DDbQsARyt3b5W4JAwXPoB8g== 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 Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 6/9] x86/HVM: convert hvm_virtual_to_linear_addr() to be remote-capable From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Message-ID: <3397b5ea-bc21-5a2c-ba5d-afc974a92df4@suse.com> Date: Tue, 21 Sep 2021 09:19:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: FR3P281CA0064.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::12) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72fb8069-fc20-4153-7ac5-08d97cd02bee X-MS-TrafficTypeDiagnostic: VI1PR0401MB2606: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TJaB1RuJ1J1TQQJVuAIWYy1Lstkt45BXC8DsTjD1KvItYVmqDHMaGVe9XhXNCDzqX4l7qDFm2Q9qxb0qWhd8wCGTeqPp6SRV0ty7bbwZGUE8nLotJ0Vs/foJQvVJXIVeFR4yYQRDdtlXKP1r0czwN+g5L3lpDmXXSm+y3xTgyEt8R+y2ycJjcswjF75kmxP18I9fRiVShgpcFARQ6d8FACbA+07mRQB+ZkdHWJg7K5uv8ExhAqj0KmgQ46aRaQ2sEoWPCK+fwz9YFKehHyoXGqj92WgqwDHyYsMVrngmJo+HP45GIg6PEnsi/PBaIOeOKd589ly5pVdTRcV7ok/3/ai2hjerGraB809PdYUIILZyV+fhkxaxlPpcKBwMDyzc1iFjtqtlnmKSrpWKzyLWAose+e+4gCgHbEzXO/pE24sLDwNV+knG6yJjk5E/q0b6ebnzP1PhCj2eDWlces5ZTCz37hipjj9q45qt2RRHw5nRRj9VRPn8VI4nGvXIl4eSvNatDkRTD9d2epVU4gsmo3MqrtBWgwqIGOSQ+0dNgla/mTWUr3/nkf2dIA6F7UyoBpv2hPny0NB5a4hqEHIfoAVkzlI3aIK1b3RnkTFJ+asIm0nsJGT8i5DjsKe8cAeKmmqidAvr2i8QlrM86LE4I0OHOnzMRCZQM45feq9g+y5VKNMy0gARvsmDzjiTRu24WQm2TEvjQvPYC+uzI6BAd5KGeXe0XEPeyhE8egt0a38= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(31696002)(508600001)(6916009)(38100700002)(2616005)(4326008)(83380400001)(66556008)(66476007)(316002)(5660300002)(16576012)(26005)(54906003)(86362001)(8676002)(31686004)(956004)(8936002)(186003)(2906002)(66946007)(6486002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?U6CgRR8L2HL1eXMcAqzSAUmp1A2s?= =?utf-8?q?VInfREdosb+m2btvcrGzq6bhbnUOzVhWoX/+8IN/SMBSmVxz2o96Y+CjM3z0t964E?= =?utf-8?q?woAhGGtXl8JjwuSDluBE0Oqc0LmK9JSev/FnBXjbUaVOibzmgfkXmTtEgSGR0oJ02?= =?utf-8?q?iuaINcdaDqVVN7gvimNdx5gU75IZwWAeAhDP3y4ED3GdTFwwg7677PR5s1bfDn586?= =?utf-8?q?rJdTJMUmpjbKrzsBj+zWvaZnwv5NzdsQq5FwMEKaPM4FPXLh9+CG5PYiq7ifFEm3P?= =?utf-8?q?cvxrusI1kIJ3sDh6Q9EkEgb7pCjVLwxmpkAcdWvHue+xwtQjjAIvw1ahOL4X9VXFh?= =?utf-8?q?OQpPF/8X1IbpfNE8P5m3vSpO2SYhP5R8w9891K+TEmr/bc6m4xkrMSyS39YKtJyl7?= =?utf-8?q?lCMirkwHle5+FjD+U+vV2a985VhmspxlkrxUqFRCRLTjcznK/ZBx8kUa+OHB9Siwl?= =?utf-8?q?sXerXIcFErCtrlCJYNcuUbjrS2Chn8TCerFro+fFASgbbbyNbKWn+4FDRcqjGD6Er?= =?utf-8?q?2kbljH0p+TZVASdagRUKiABuVS1uhoDvX3EYKw20AZN1GxB+Pd8zmBxsP+kDAsp6Y?= =?utf-8?q?FBp85pNk9K71KuAbJCbCZXgGftqeDcpWGKI6y69ExHCyQXifLiKouqkaoxJkiKpSe?= =?utf-8?q?iPrmg162jqioBBNZDPz+BzBHkEayqtsj4CDzM7wRO0IkcwTHAz3xCMY2J2Cs0Codk?= =?utf-8?q?kb8EvdEnlRnpvXYNsungK27RmdjswIouViwR1UeZCHujbYdphqjs/CzWpu3+ogNsy?= =?utf-8?q?pP7ltJ2KWwd4wFuhXNSkSbGi9z22h/xYDM+kyttnwVj+VGeJNv4qqew9ghKSKOaB7?= =?utf-8?q?Wn4KDHo8JEUaPkYkrs2aI6o26XMiFV3WmPxvGO3oEeTyOvFRoMvDYf15XrPUqnn8P?= =?utf-8?q?J0JReF838eP0xgjUbGNp2+HJxd6dz8BTyZ0vxn6felwm6uCxq3RPSeecYNzY6pVDL?= =?utf-8?q?5vhCLw/1Mx7IiyDYzgTQGlpJYeuEn0DDG4FmvYQUE9vJ0LjQUtVVfgQP0xb+vFyl0?= =?utf-8?q?HjNBuJuHpf0Y5TC2cMiNZCJcukfHJcP6wBn6swTGXFa6e8mc2STBpcYOyr/IbynPB?= =?utf-8?q?6Os8us/HPyMt6JkZZxMmdAsFC8MxRsJv9MGgR7EXeNohN5uBJCbhLC1DDuXaf63cH?= =?utf-8?q?cM2kqoXMAUJ0s6ZghqHD7UwOegdX0+s5xj0iZzefkuL74DdcLpL6b+XAAHpqRnwye?= =?utf-8?q?5Qz6BEiEiT6Q3BFCQcSIg9GWO1uJ0YN3XWdK+hwHn9EY8kKN4BORMZ/F6qciG0TM/?= =?utf-8?q?27rcPNIB/HFhAgkO?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72fb8069-fc20-4153-7ac5-08d97cd02bee X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:19:38.2846 (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: fpgVTVTSozs3rU/tqjja6EY4bOmQ/8bVed01uRMqnAGv7w4Px6N0MICPRM1KaCQzTzwZC8/c2+At0QdMUFcgdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2606 While all present callers want to act on "current", stack dumping for HVM vCPU-s will require the function to be able to act on a remote vCPU. To avoid touching all present callers, convert the existing function to an inline wrapper around the extend new one. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné --- Alternatively the actual dumping patch could avoid using this more elaborate function and, ignoring access checks, simply add in the SS segment base itself (if needed in the first place). --- v3: New. --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2526,7 +2526,8 @@ int hvm_set_cr4(unsigned long value, boo return X86EMUL_OKAY; } -bool_t hvm_virtual_to_linear_addr( +bool hvm_vcpu_virtual_to_linear( + struct vcpu *v, enum x86_segment seg, const struct segment_register *reg, unsigned long offset, @@ -2535,8 +2536,9 @@ bool_t hvm_virtual_to_linear_addr( const struct segment_register *active_cs, unsigned long *linear_addr) { - const struct vcpu *curr = current; unsigned long addr = offset, last_byte; + const struct cpu_user_regs *regs = v == current ? guest_cpu_user_regs() + : &v->arch.user_regs; bool_t okay = 0; /* @@ -2547,7 +2549,7 @@ bool_t hvm_virtual_to_linear_addr( */ ASSERT(seg < x86_seg_none); - if ( !(curr->arch.hvm.guest_cr[0] & X86_CR0_PE) ) + if ( !(v->arch.hvm.guest_cr[0] & X86_CR0_PE) ) { /* * REAL MODE: Don't bother with segment access checks. @@ -2555,7 +2557,7 @@ bool_t hvm_virtual_to_linear_addr( */ addr = (uint32_t)(addr + reg->base); } - else if ( (guest_cpu_user_regs()->eflags & X86_EFLAGS_VM) && + else if ( (regs->eflags & X86_EFLAGS_VM) && is_x86_user_segment(seg) ) { /* VM86 MODE: Fixed 64k limits on all user segments. */ @@ -2564,7 +2566,7 @@ bool_t hvm_virtual_to_linear_addr( if ( max(offset, last_byte) >> 16 ) goto out; } - else if ( hvm_long_mode_active(curr) && + else if ( hvm_long_mode_active(v) && (is_x86_system_segment(seg) || active_cs->l) ) { /* @@ -2636,7 +2638,7 @@ bool_t hvm_virtual_to_linear_addr( else if ( last_byte > reg->limit ) goto out; /* last byte is beyond limit */ else if ( last_byte < offset && - curr->domain->arch.cpuid->x86_vendor == X86_VENDOR_AMD ) + v->domain->arch.cpuid->x86_vendor == X86_VENDOR_AMD ) goto out; /* access wraps */ } --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -314,7 +314,9 @@ enum hvm_access_type { hvm_access_read, hvm_access_write }; -bool_t hvm_virtual_to_linear_addr( + +bool hvm_vcpu_virtual_to_linear( + struct vcpu *v, enum x86_segment seg, const struct segment_register *reg, unsigned long offset, @@ -323,6 +325,19 @@ bool_t hvm_virtual_to_linear_addr( const struct segment_register *active_cs, unsigned long *linear_addr); +static inline bool hvm_virtual_to_linear_addr( + enum x86_segment seg, + const struct segment_register *reg, + unsigned long offset, + unsigned int bytes, + enum hvm_access_type access_type, + const struct segment_register *active_cs, + unsigned long *linear) +{ + return hvm_vcpu_virtual_to_linear(current, seg, reg, offset, bytes, + access_type, active_cs, linear); +} + void *hvm_map_guest_frame_rw(unsigned long gfn, bool_t permanent, bool_t *writable); void *hvm_map_guest_frame_ro(unsigned long gfn, bool_t permanent); From patchwork Tue Sep 21 07:20:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507355 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 7CEE5C433F5 for ; Tue, 21 Sep 2021 07:20:18 +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 2B1FD610E8 for ; Tue, 21 Sep 2021 07:20:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2B1FD610E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191441.341471 (Exim 4.92) (envelope-from ) id 1mSa4W-0007cJ-Em; Tue, 21 Sep 2021 07:20:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191441.341471; Tue, 21 Sep 2021 07:20:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa4W-0007cC-B0; Tue, 21 Sep 2021 07:20:08 +0000 Received: by outflank-mailman (input) for mailman id 191441; Tue, 21 Sep 2021 07:20:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa4U-0006mE-T7 for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:20:06 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ea372172-ccdb-4c2f-90ab-494e8ddfb4fd; Tue, 21 Sep 2021 07:20:05 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2059.outbound.protection.outlook.com [104.47.14.59]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-37--c95hKXTPcSNhYd3da-yQQ-1; Tue, 21 Sep 2021 09:20:03 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VE1PR04MB6671.eurprd04.prod.outlook.com (2603:10a6:803:11f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Tue, 21 Sep 2021 07:20:01 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:20:01 +0000 Received: from [10.156.60.236] (37.24.206.209) by FR0P281CA0085.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.6 via Frontend Transport; Tue, 21 Sep 2021 07:20:01 +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: ea372172-ccdb-4c2f-90ab-494e8ddfb4fd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MZzQEVSwMvpFC6oSCiycTUs10fXX3566gSFd9Uc4olw=; b=JXP0PggS2U3EhnABGu1I2a2qo5wFco509ahINW49DEFxO594EwdSbfIjw62jI7CJBshKLt HJiWUjwu3bMdVEMCA6FPYPHKbFEqldpB2zfqsHPBNcG+gLt0Sq4X1jLXOZ035bVCeMpp4F 4Sj78WSLK/4hHT6phu4Uj9xnDgdrPtY= X-MC-Unique: -c95hKXTPcSNhYd3da-yQQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m+wLz7rUWazxE3ro99PvPgrXKeZg+rN2omAHPbRjJ1TNh0fU4BpYmBQBFvsbnSBvgF07flbm+kRHW8u4U8gpxqyD0qrvFHgv6u9Zx4kBMkakvTiqvBExuf5rwEjFgIqBY6ZXOSU1QUIId1FyZLHGT9KDYrAXULO84/2pVq6jY32WbBKrieh3pg2Rbg6EiFe+fznTa6igeEskY3zlI8/0apqv6aVZZViVovqKIkoS+mt5COOWukCvXCFn/f9RQiqu2WAIgUQSJ6sfsSEUD+XSwUgAGvvnkJ+94t+AoeWk0ZnUGOnDP1YkUxV0l/P2YQyKWbI629nAxhTA9m/LeDZPjA== 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; bh=MZzQEVSwMvpFC6oSCiycTUs10fXX3566gSFd9Uc4olw=; b=K3y5uFsuNLVTcVxz8jQOixhnLy6nrnqZLhAsbdWRnVdaaIN2fz+sWSy7p6Yc4IZH3gAQUMzcj6GplTjbfk44sFgfJOromeZIDKmMufd1Z44w9sae38df8MC4ietFPPXzN3HjvoXtekk4DlAJ9cP17hQzLbWkjgDxIk9G8IFpAbx/K6s74Vh1k6WoXTHNYNkOsLjUXZgV3Vxadk6AfL+odkWkiKQR1SeycLc63Yku9ogPDh4yc9GrkHSlWsMobsei1bFe6S6tfW8k6Wz7bBJZT4Ec5i+q3ThyI6yxVDGC+aqpXU/6fR28S2oeoRMmp8c+B87VgB+1NyAwpvHk9+Hycw== 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 Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 7/9] x86/PVH: actually show Dom0's stacks from debug key '0' From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Message-ID: Date: Tue, 21 Sep 2021 09:20:00 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: FR0P281CA0085.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::9) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70b068cf-b07a-4023-e6c1-08d97cd039a6 X-MS-TrafficTypeDiagnostic: VE1PR04MB6671: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ypZOEBrTsAT+Duv6+keWmuQFg/TsTMyfj7JJSuAvmLeKnZXxIsjHwPqRsrqt1+38Hu13BqX4I9F4fSIPmdE8pAVHA/qNGbaGl9o4+m5c56zSLIhdYE2vqIFbWl8x8pgOYM8lMsIcV9nk71H4guHg6cQzIQmwugOixAtVGVHgpRNufNEdhD+wzR8kwk5Er+UgdpwMVbXwmjMKQnnzqqLcH2GHcReUWfsU3RIQ/HH+5RihhzqpvP4wT+qtUHRO52PGiraa6ogXY9bTpUfI24kSoUiSczPCufOFk+RQfjvk1u+7rAU1q7CIImcJ9ijin2xM9d/pI1prkB2NfIM5Ub7VyiVtlJ3DNxwZ1NS7++mtU/h9s4XZoC5jeLpHReDW4Itcoa8jtjNCjxFf2bzUdS5m1YVtXHJ7JRq0d+2fUZJ5ww/CnGbgF+GMnhezRPLsqtitbLyvz5QYw/yeFt+EKdMukNns0KzP4x4EvEWR3jdTXJaOSoaDe9t9bkBaPt65HhJtpkbVwOJq8hor+FVhpOBHjpbaRc/BGY+FGmsV07t4658vKbBettuDndbjV0u2TYmsMKBLjbptE/5rJE5WsJcuSkKDcnLbu5O905bsEydC6nv3uzYtcplV/S/2zg26PKpDEkZrUOv3qlOS0oE3pQ+VzdkyEqZxJq033G2YpiM3aP8rGgdsjZIwomlnniAJur0pMIqIpmS/q5XZWhVmiqSs1nMWa3BhO0bzWISCjFK0vYc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(16576012)(5660300002)(36756003)(54906003)(4326008)(8936002)(956004)(31686004)(83380400001)(8676002)(2906002)(6486002)(2616005)(26005)(316002)(38100700002)(186003)(31696002)(508600001)(66476007)(66556008)(86362001)(6916009)(66946007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3ULmXvzWGNVbqKc4ouOHK++pLi/F?= =?utf-8?q?Fyg4cQt5/X9APRC7MG3ppRbybgLsX6zRAS2hyMz52xfwWj0N0YV/UVBCJQxkGIUUv?= =?utf-8?q?Ohb5tpcvkvaNMxwnPoOQeYMli7cdch7/pU/4p1mYb3cO/jvOJmTtYtxlDGyZHCFOU?= =?utf-8?q?IRWVCrocrObhkmbFT/SVbLQcaiLMrHkT1STxqr1AZTUBf53v1BwJdD8B8XAIqaPdA?= =?utf-8?q?0mXMjEkE+txv4tl09OdW6a2mOwLaB+cFuQ7E9uPZaLfd9GTnCNMZn6xJEOMiUAF4V?= =?utf-8?q?mzzDnOEPYJCOzQ8GGbgMQsmDlr2R8LjYkvDHybmuJQdU/3zYQ0Hzoi8P9X4gkq1dG?= =?utf-8?q?enj/rlzBUsPq3mMGscUCcI69X+ra2xVFPIx971sFjEAm+03cTx/ya2/WVBv52sw2Y?= =?utf-8?q?r+koE9KEsL2hVTSNhb6rct3mYam9ialho5EmBoyBQyjSJ1boExKsKhKtrQkCtK6om?= =?utf-8?q?qQsXijZtUFNGVWcDOG09J/XduW7/UOdNdW2cTxDAedaZraI6uA7+Ya2giBCxhiHG1?= =?utf-8?q?R80QWh24+cWVV2AuXKkENJrhFSMZ9N1w7aFZeyD1Xfx5DL2joDBXeNP0wOOr1IZ0S?= =?utf-8?q?Nq8EFZ7ZRVa83rIQjfhQaHVTTqOtNd4v3uJL2Gn0Nd4c6l8SEU6FVs+vNXGg621wg?= =?utf-8?q?6bxw03RlpibP5WGa8xWpuCvEkNX4iCD8zqpkhqAcUMQoRJp0w5lR3zEOPLXe/UUp7?= =?utf-8?q?ublffpZChAnKoxsEKOMDq+FrkghXu0rfPja1HUXNrvPiAegLO3JYvITx/vZ23Yojs?= =?utf-8?q?3SYgOx6IZhz5j91X9ZWTB+/JtgzJwISSevBst3M6YGoi2AWOYzHJyC1P7yu0097EA?= =?utf-8?q?NFDoo9PjbJuDD8KO8SCSILR8wsKHXvSP+Blzcylli898OKWp+h5lTJE6nZgJhzF2T?= =?utf-8?q?WvMPh0CzjLMDKNSIpZdCO4II59J8/I2o7fUXQkHH699T82/h2Gc0r55dKfApBK4NM?= =?utf-8?q?GlLNUIL9QdvrgmGSLQ2OZRy90MRWgaOfleaOz5LkXlmtVWRSTiogNaT/AUOYltQ6r?= =?utf-8?q?JcdIdDGvqxyP2WwG6SuoYRk9GDy6A7CsYMYxM6JhdesoNe5dj0dl6JQs1bOTp363M?= =?utf-8?q?M0vgm622+tRFMtk6gOX6cWNMEFPVhDMQ3VEECIA4VCdRuLsFYfr2+OwIxjscs6Yt9?= =?utf-8?q?sOx8s86b9RrWH4A4f234GKz4rPVBHoV+Ci8bFAMkiQWPb+X8uCDiNKmoF2QS05oP5?= =?utf-8?q?ycs3TLISgnrah7eTew8K8lqw/w1uvLg37mN2QyMA6RpIq+z1F3D8qju8Zs/YtURye?= =?utf-8?q?AL4pQ8xK5QtSSEAm?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70b068cf-b07a-4023-e6c1-08d97cd039a6 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:20:01.3126 (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: hL/QSQ+Zpz0CjVJwdWTX2QIwh5ASu6sMr8v45kLAsiVJlOH4Uyju4S/xSCTE6SXYttuSJjGRKMa+cWg4lG/hog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6671 show_guest_stack() does nothing for HVM. Introduce a HVM-specific dumping function, paralleling the 64- and 32-bit PV ones. We don't know the real stack size, so only dump up to the next page boundary. Rather than adding a vcpu parameter to hvm_copy_from_guest_linear(), introduce hvm_copy_from_vcpu_linear() which - for now at least - in return won't need a "pfinfo" parameter. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné --- TBD: The bypassing of the output interleaving avoidance isn't nice, but I've not been able to think of an alternative. Avoiding the call to hvm_vcpu_virtual_to_linear() would be in principle possible (adding in the SS base directly), but one way or another we need to access guest memory and hence can't sensibly avoid using the P2M layer. However, commit 0996e0f38540 ("x86/traps: prevent interleaving of concurrent cpu state dumps") introduced this logic here while really only talking about show_execution_state(). vcpu_show_execution_state() is imo much less prone to interleaving of its output: It's uses from the keyhandler are sequential already anyway, and the only other use is from hvm_triple_fault(). Instead of making the locking conditional, it may therefore be an option to drop it again altogether. TBD: For now this dumps also user mode stacks. We may want to restrict this. TBD: An alternative to putting this next to {,compat_}show_guest_stack() is to put it in hvm.c, eliminating the need to introduce hvm_copy_from_vcpu_linear(), but then requiring extra parameters to be passed. TBD: Technically this makes unnecessary the earlier added entering/ leaving if the VMCS. Yet to avoid a series of non-trivial enter/exit pairs, I think leaving that in is still beneficial. In which case here perhaps merely the associate comment may want tweaking. --- v3: New. --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3408,6 +3408,15 @@ enum hvm_translation_result hvm_copy_fro PFEC_page_present | pfec, pfinfo); } +enum hvm_translation_result hvm_copy_from_vcpu_linear( + void *buf, unsigned long addr, unsigned int size, struct vcpu *v, + unsigned int pfec) +{ + return __hvm_copy(buf, addr, size, v, + HVMCOPY_from_guest | HVMCOPY_linear, + PFEC_page_present | pfec, NULL); +} + unsigned int copy_to_user_hvm(void *to, const void *from, unsigned int len) { int rc; --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -364,6 +364,71 @@ static void show_guest_stack(struct vcpu printk("\n"); } +static void show_hvm_stack(struct vcpu *v, const struct cpu_user_regs *regs) +{ +#ifdef CONFIG_HVM + unsigned long sp = regs->rsp, addr; + unsigned int i, bytes, words_per_line, pfec = PFEC_page_present; + struct segment_register ss, cs; + + hvm_get_segment_register(v, x86_seg_ss, &ss); + hvm_get_segment_register(v, x86_seg_cs, &cs); + + if ( hvm_long_mode_active(v) && cs.l ) + i = 16, bytes = 8; + else + { + sp = ss.db ? (uint32_t)sp : (uint16_t)sp; + i = ss.db ? 8 : 4; + bytes = cs.db ? 4 : 2; + } + + if ( bytes == 8 || (ss.db && !ss.base) ) + printk("Guest stack trace from sp=%0*lx:", i, sp); + else + printk("Guest stack trace from ss:sp=%04x:%0*lx:", ss.sel, i, sp); + + if ( !hvm_vcpu_virtual_to_linear(v, x86_seg_ss, &ss, sp, bytes, + hvm_access_read, &cs, &addr) ) + { + printk(" Guest-inaccessible memory\n"); + return; + } + + if ( ss.dpl == 3 ) + pfec |= PFEC_user_mode; + + words_per_line = stack_words_per_line * (sizeof(void *) / bytes); + for ( i = 0; i < debug_stack_lines * words_per_line; ) + { + unsigned long val = 0; + + if ( (addr ^ (addr + bytes - 1)) & PAGE_SIZE ) + break; + + if ( !(i++ % words_per_line) ) + printk("\n "); + + if ( hvm_copy_from_vcpu_linear(&val, addr, bytes, v, + pfec) != HVMTRANS_okay ) + { + printk(" Fault while accessing guest memory."); + break; + } + + printk(" %0*lx", 2 * bytes, val); + + addr += bytes; + if ( !(addr & (PAGE_SIZE - 1)) ) + break; + } + + if ( !i ) + printk(" Stack empty."); + printk("\n"); +#endif +} + /* * Notes for get_{stack,shstk}*_bottom() helpers * @@ -629,7 +694,7 @@ void show_execution_state(const struct c void vcpu_show_execution_state(struct vcpu *v) { - unsigned long flags; + unsigned long flags = 0; if ( test_bit(_VPF_down, &v->pause_flags) ) { @@ -663,14 +728,22 @@ void vcpu_show_execution_state(struct vc } #endif - /* Prevent interleaving of output. */ - flags = console_lock_recursive_irqsave(); + /* + * Prevent interleaving of output if possible. For HVM we can't do so, as + * the necessary P2M lookups involve locking, which has to occur with IRQs + * enabled. + */ + if ( !is_hvm_vcpu(v) ) + flags = console_lock_recursive_irqsave(); vcpu_show_registers(v); - if ( guest_kernel_mode(v, &v->arch.user_regs) ) + if ( is_hvm_vcpu(v) ) + show_hvm_stack(v, &v->arch.user_regs); + else if ( guest_kernel_mode(v, &v->arch.user_regs) ) show_guest_stack(v, &v->arch.user_regs); - console_unlock_recursive_irqrestore(flags); + if ( !is_hvm_vcpu(v) ) + console_unlock_recursive_irqrestore(flags); #ifdef CONFIG_HVM if ( cpu_has_vmx && is_hvm_vcpu(v) ) --- a/xen/include/asm-x86/hvm/support.h +++ b/xen/include/asm-x86/hvm/support.h @@ -101,6 +101,9 @@ enum hvm_translation_result hvm_copy_to_ enum hvm_translation_result hvm_copy_from_guest_linear( void *buf, unsigned long addr, unsigned int size, uint32_t pfec, pagefault_info_t *pfinfo); +enum hvm_translation_result hvm_copy_from_vcpu_linear( + void *buf, unsigned long addr, unsigned int size, struct vcpu *v, + unsigned int pfec); /* * Get a reference on the page under an HVM physical or linear address. If From patchwork Tue Sep 21 07:20:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507357 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 F0D9CC433F5 for ; Tue, 21 Sep 2021 07:20:55 +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 9F3D2610E8 for ; Tue, 21 Sep 2021 07:20:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9F3D2610E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191448.341481 (Exim 4.92) (envelope-from ) id 1mSa55-0008Eh-MO; Tue, 21 Sep 2021 07:20:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191448.341481; Tue, 21 Sep 2021 07:20:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa55-0008Ea-JQ; Tue, 21 Sep 2021 07:20:43 +0000 Received: by outflank-mailman (input) for mailman id 191448; Tue, 21 Sep 2021 07:20:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa54-0008Cx-9A for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:20:42 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.111.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f0407dc2-183f-450a-b795-8acad6bbd819; Tue, 21 Sep 2021 07:20:36 +0000 (UTC) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2110.outbound.protection.outlook.com [104.47.17.110]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-34-YjvEN7OzPWibYAIKPIA3Ig-1; Tue, 21 Sep 2021 09:20:34 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VE1PR04MB6671.eurprd04.prod.outlook.com (2603:10a6:803:11f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Tue, 21 Sep 2021 07:20:33 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:20:33 +0000 Received: from [10.156.60.236] (37.24.206.209) by FR3P281CA0037.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.7 via Frontend Transport; Tue, 21 Sep 2021 07:20:32 +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: f0407dc2-183f-450a-b795-8acad6bbd819 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CbSaBreuvDjQILv0E6xjB0s8ZsBQ3dj8qUpxvESe3zI=; b=jPvUgl3iBo76LX2XzOrKWskJdjShK5UQYY4OcrOnztuhXqloEpItzsGulgPMJ9F/MQqWcT I6CIZogN73IY1ZYwIUVL9fxfE2WFvRu4pqMVVw2vxawXklT4MnmBQbNityreOcEd0MWMLb ZS1LayiELZk1CoxFFTrPbSOgTFho/jM= X-MC-Unique: YjvEN7OzPWibYAIKPIA3Ig-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B2LUX0fRf98D5C0FwNwL9PbS7MLydFyLc2nBVrxWhqNeWhyMcotO4TF5BCnrHIn1tQMdOf7ThpICfDeoKJu0/WFA7j0ux2dmw/MvSlDpg/cZbGoYnB2bdXym+xYbUURDnc84ycAvJv+S3B3PWcvTPkOEyWem/+jdOVegbm35JnOo6FAlJ2z/PSFMbchyamF7rFq+fUpSBCBXa+bqBffP1JXFR7+bl2wCPsBNsSL8DbK0z0Pov6UViUT4aOq+pOyXgXJd34gg/A+69qqJP8ftO8S6P41xChozLhegmSvONpKJt23FtrxNXYO79obOdSiwTispji0a8fQrfAT9U96w0w== 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; bh=CbSaBreuvDjQILv0E6xjB0s8ZsBQ3dj8qUpxvESe3zI=; b=IkEnAcKI3UGrNqS9FrEQ3+KQroOdo4HZHmxOSqhPlqPIFEKd/hK0kRv+mMPPA1rky+dq9nD7MzLD23xOjsLQ4a7OpuBMN1Joo8OHA5woI1wX2asxkGsVbomgY8RYdT//RU/hWNheCkU1GsOmBbUs76PKEfuIxc3e5DbAZEDbDfdoT8KK/D5WHSin1453/ZvhAR1J+xVLRfT1rl9j5YzH/uznRObi8+Gx0rapo4AnAIucujWvH5ic1qbbjod+q1mdZrt4wHjxT74k0lXu+lH7A6fVW1eKrdDUycFZVx34DLt88GDG6bDFIm8gbKNvFMO5PPCtcPe1HK7hvSS8j0MDFQ== 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 Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 8/9] x86/HVM: skip offline vCPU-s when dumping VMCBs/VMCSes From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Kevin Tian , Jun Nakajima References: Message-ID: <5cc8f7e0-399e-f6a5-bc84-823a6160a3f1@suse.com> Date: Tue, 21 Sep 2021 09:20:32 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: FR3P281CA0037.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::21) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ecc65e8-c135-4a84-0244-08d97cd04ca8 X-MS-TrafficTypeDiagnostic: VE1PR04MB6671: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:457; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PspKtaJDObcgXZuFO5ezZYYAMCqnCQ2LFc39jrxaWC9NbppUQE3K97BNrjXFFkCH3xEvrLuwfKpX81wNVBHAE+EDmUrk5oEp2IPRUfYjjJQBQCSLyIb3YtaX4DhEtGxsaMYRCaMJsFUN4sSm3a95FiSSpsUX7eVlIwWuJve8N+lOrMBCCUtbvJRc34kBdISL9vvq5dz7GqyS60MULdD4QRLSJWiF6T7rSAV3OB2Ii+8L38nJjE7tlK3qa3JmgBU+eMRaadh9DkNiL4Hrdn31mP8haTOyW+U7C4UU/sTGEI6BCL0Gq/9DEKbEs+NLPTfZf9P2iFuc9G+BVQKZ3dQ/PhFHVqbuwZxks9XSyca06bsHIiTSMDkFMq2JZkzMs6NnpIsDJWd6UZkIPqi8DlM5e5TXthuKfjikguRYAhOLWUjxhoYybnXzEAZSVkO+5Q3ppQcJ/Rg+J12znDfnH/6Yiiuwbb6R2qp270TqSbOUUnemp61SU7eAvwfjWMpiPaLiqE9cu+d0bUHMe0gYZpradihz6Sd9mZVBI2YPaTw/uIY6xEFmcegqQhR8qiE6Vj5gO1mgqKRA8SeSLMJDL4I0LJKxRdYp0WNDImfysap5ODgAHQ/URUty8P0i5B4e7nBgOEa1/kRxCSKakfcIA+N2JmAeNHblRNjQSrOi7qjDmf//Q1PhY7XmNuqIL1A+t1KE7SvSBkro196sfYcAAnjfddjSQ9xJFfnr36W0Z5iabB0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(16576012)(5660300002)(36756003)(54906003)(4326008)(8936002)(956004)(31686004)(8676002)(2906002)(6486002)(2616005)(26005)(316002)(38100700002)(186003)(31696002)(508600001)(66476007)(66556008)(86362001)(6916009)(66946007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4eXhCKrrDmEgEK37pooHm6sayt9x?= =?utf-8?q?c1fr6Mb/YCS02o470DrWH4anTTQTPsRRvKJ3YVhNa2kvhtSp12bclbH+2newoTf31?= =?utf-8?q?LdU7gPZlAoMofAUPvvK4gVQNw9MxxU4vKaRFOZWqtrEfPJaxJAelvjaAHIHm9v0Gl?= =?utf-8?q?gaFVKxAx+oAmV7oQpTxCjYoSprFHLC5sf+wROczOD/HgMUYRbtENwBLWpEvS5k7ap?= =?utf-8?q?lnzr7cOXbg7KSRJSIGeNkFJOIi6fH7tQIehQ0LOPkPh5AIV9dW9xuh8fjKUAqIaFd?= =?utf-8?q?8dxP7OwpL4+0OURvzEOOo6nAk5ZimxGtJeo5PhY1utZW2K9fl4SeTG0JZnrg6PsXv?= =?utf-8?q?m9s/2oDcan8O/ggzm+vRqe2B9GYxslffOisdJKzSOO6m8+nAwo6nlESRkz/74a/nu?= =?utf-8?q?7aoiqIFukahSo29z7JUViqB06pFW85l0TjFOvnr50Kw01M+ebppwx27A4kObFtemF?= =?utf-8?q?aK87b3Aqauz1C8B1ro//3VMUNJbGdWEQNmciKoJeJSmfJgJcraJEjMDEeRPo8zLxw?= =?utf-8?q?7ySHsRsslNdanQkhux0M+c457wlbiJcdMH7sIUOyhoptGIMfoB/OV6LGsrShsGWse?= =?utf-8?q?zUajitHGWGWnR6Ky4kIIeN4NHVjQe0zn1V5uOIY0akhyU/n2TuhoA1q7Tz37Oxh0O?= =?utf-8?q?BxpnBCuUJyO8L7HOxedg937zIU8YXAwUY+3nJgdkUeNwM+gOcv2bx1vQMQIEPmO1z?= =?utf-8?q?pGjaCX9konbghqqSMIdYAtcekFXwTJy9DEkJ17/BJuzvAYVN9GjUVlwdnQIB4iDWY?= =?utf-8?q?nyBztwN8MjKdMnfEI3lOL+5Nm9KMPFCY3OcLqkTJz0hRXoaZv7A9vIF2pnk8dlQT9?= =?utf-8?q?PpVsd48wXz3raOoaVnp4rwkIlQMX6lBctxQNEJlcGslNDWLWGjYg0qmxaoRBNSJMr?= =?utf-8?q?4W+5EgdJXr1WCU4HnxweqgFyDOQ92AhwfbZfU7sPWri2NAgtRGitQ11PAELxivqvi?= =?utf-8?q?xDZhv0dviEmN/GZZnpmdMOv8icrGopiHLIxC4m8F59Kt/4mJcOgMyfV9xdFbEXQFY?= =?utf-8?q?nglANcb93KoOkBWOfvuqiSjadPpkO7JX4CIc1D92Rn/57eJkCUpYK67BDtgjCOvN1?= =?utf-8?q?/sW++rUGWmXuZwztiChEnq1diZHpa6IQ786YmhXVmaCjckxDELcg+bxqclq+S8rs/?= =?utf-8?q?FEZKES/NN88qxhsQrLa5ZdQv24FxRdbBDpxA72X2r6Dxc95WLZ8qLchoLPmLI1zhO?= =?utf-8?q?NXLJo3jS1iH/xUNjosihOb/tAMbHqUB1QGc/yW2Cj+72J/BNvL96YNSman+gYhI/5?= =?utf-8?q?1TxbhvsapIZhkLFB?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ecc65e8-c135-4a84-0244-08d97cd04ca8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:20:33.2615 (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: RgPfGZOkr2v98P9Xz74vU+6aCkg3Sz0TnOE1pZwNrNFjEX2/aWGdX4f0P8Whuu+Sxypi3guUlsgznY+azludWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6671 There's not really any register state associated with offline vCPU-s, so avoid spamming the log with largely useless information while still leaving an indication of the fact. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné --- v2: New. --- a/xen/arch/x86/hvm/svm/vmcb.c +++ b/xen/arch/x86/hvm/svm/vmcb.c @@ -242,6 +242,11 @@ static void vmcb_dump(unsigned char ch) printk("\n>>> Domain %d <<<\n", d->domain_id); for_each_vcpu ( d, v ) { + if ( test_bit(_VPF_down, &v->pause_flags) ) + { + printk("\tVCPU %u: offline\n", v->vcpu_id); + continue; + } printk("\tVCPU %d\n", v->vcpu_id); svm_vmcb_dump("key_handler", v->arch.hvm.svm.vmcb); } --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -2133,6 +2133,11 @@ static void vmcs_dump(unsigned char ch) printk("\n>>> Domain %d <<<\n", d->domain_id); for_each_vcpu ( d, v ) { + if ( test_bit(_VPF_down, &v->pause_flags) ) + { + printk("\tVCPU %u: offline\n", v->vcpu_id); + continue; + } printk("\tVCPU %d\n", v->vcpu_id); vmcs_dump_vcpu(v); } From patchwork Tue Sep 21 07:21:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12507359 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 179F0C433EF for ; Tue, 21 Sep 2021 07:21:27 +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 BA750610E8 for ; Tue, 21 Sep 2021 07:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BA750610E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191453.341493 (Exim 4.92) (envelope-from ) id 1mSa5d-0000Pz-WD; Tue, 21 Sep 2021 07:21:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191453.341493; Tue, 21 Sep 2021 07:21:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa5d-0000Ps-SZ; Tue, 21 Sep 2021 07:21:17 +0000 Received: by outflank-mailman (input) for mailman id 191453; Tue, 21 Sep 2021 07:21:16 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSa5c-0000Pc-LR for xen-devel@lists.xenproject.org; Tue, 21 Sep 2021 07:21:16 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 818cb834-1aac-11ec-b89f-12813bfff9fa; Tue, 21 Sep 2021 07:21:15 +0000 (UTC) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01lp2054.outbound.protection.outlook.com [104.47.2.54]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-17-NZpMd9o3NHGFH53cbEF2jQ-1; Tue, 21 Sep 2021 09:21:13 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR0401MB2606.eurprd04.prod.outlook.com (2603:10a6:800:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.18; Tue, 21 Sep 2021 07:21:12 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.018; Tue, 21 Sep 2021 07:21:12 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM8P251CA0011.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 07:21:12 +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: 818cb834-1aac-11ec-b89f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632208875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=289UvYu1z6hhybJctb/uHf8lFebZQ7uBwKVUfRIW7tA=; b=afw0ncX6rYa7tvfD5HOD2sPq3eF6QDjKjAvIGuFNjgIDwarx+2I952rScdokzWMfVzD8ml UNqpJ5Ar89JQa1q6A2AsOjdPk9pZwnadCJTugo25XP/8Ux1jVidjTO9XQoI6oOFoSR73zL c0ouiekY0rFJSavIDHU0aCo0UIpsOvw= X-MC-Unique: NZpMd9o3NHGFH53cbEF2jQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P7aoENOHdv05H6wD0zheCMqSW1MX2nF+sHjcYjtaB3EO4dC2O/19CrQ4Et6uI19rpH7WXN3O6kmEZZIRRDbPfYTKEk9r+RV7PCxCw/MWIHX9fiF7FZbV6CVCnUCSEMf+bx1duV5xGu2hfPdPIDf6F6cwhjdZ8WoXJB1+XxJaJdjMwNMTnyahWN/eyi+uKBY6UAt7x0f5unB3ien31m7xdWaM9oCZBU8rpMCaDuwmdExK3dwJOiK8/dMkR2xCIfJd0vi7vVpvBG32Z06QJAPw5qRmCqZGGFWEKEbL9YJwttlhuz+m0DOXurVdbCTFUF3Py+L3cNJ3uDJKgq669MJ3iA== 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; bh=289UvYu1z6hhybJctb/uHf8lFebZQ7uBwKVUfRIW7tA=; b=AOF75uADfuJNL8vrXQcOnddp+d/kjjIjs5X6zBymE1miaFCm91NlLXeGcqm+Ols9oV7K2FioYGZPgkHp+2uumS0cFm2sPt5gVfSClWMFvALYDtPR6vFxjw4fqXNA8ip3jTC/OAdxrCuepjICpTPYPjYaepfxpW6xC8pnRdBFlh1aIVkVHWStDidfAWwTxEjr5zCtaGK8IGrgfAY1uFoUluxerUtTvjXapxh2eHOyVxAx9g6xlyEbp17zMGVE+j50gHlsG6ih7LsAam+9PJIVoz1JMyL3zyghKRK3Uoq7KLl+jTdHOOkdZ027uRU09Q2uZFnyGAcnzGtDo0jj3xznlg== 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 Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH v3 9/9] x86/P2M: relax permissions of PVH Dom0's MMIO entries From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap References: Message-ID: Date: Tue, 21 Sep 2021 09:21:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: AM8P251CA0011.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::16) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e7988f48-3e17-4028-d6bf-08d97cd06436 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2606: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GEQpZvVC4gjo4LApWhDyUqClHh7Tc+bAnChVMDRBSrkRpWXHc7wfDKhk9y/owPSexYzIPvKD6GURW9j7/4m3w0b4OuvTVAdq0boRma29bJmBCV2bsA8AWt1QkJhB5PgAXsMJC0rzMJ8B5oM4xXR3U4iTydY/4mfySF2EpGjObGSUiCoOwF272fFQaLhoO67bukLlchc6Q2mjpK2FetRXTPUt7MRS3TmlpAVz3cJZTbEZdrVAOXuWLJxI0SJWIZ+ARdkotTYXdpNjPW+LxCgxrl96IJIiGNpirxCe+GE3xRaLEaSN97CdEyEDFiiUHSaq8eRK8rjJbTMKrjTrdtZBTgcBytZvvs6q8W0Iq8C2o4nc0znfY5WySyRq+gcyIZ4lSkqaon2f2OViLnKoVqRgj36sblhUKDxAO7vztU9iB7IA4mgSUSjN+KejSowVseaBn6WYzpoEoeu93up4Rof+i3FX4fhFL42DqzEEet6oT57jekftueJ76+vBTo16jmpImzHmCiGdmD645giercuGpANwKDMPVMdxs01l1WHP0eOz1e2FOWZCWnq9fecaTV+rrSLL1sVDx/nVsYcld4JDckN57yoewJnXkGF1pU/zaFPH6XYupnRzApz/0Qi1OCmh1BIkZHh+u/OZaD+bVkQR1ss8QgxPFKizTsJtmDYIzQbsaWsQDh4FUDmnHaGK/tW7jlBlP8bElI8ACm5rwd+yUfGKoNF3Pk5+7SInFrXlius= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(31696002)(508600001)(6916009)(38100700002)(2616005)(4326008)(83380400001)(66556008)(66476007)(316002)(5660300002)(16576012)(26005)(54906003)(86362001)(8676002)(31686004)(956004)(8936002)(186003)(2906002)(66946007)(6486002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fkCZpEft1Gcm1DGHD9c2PJKMsOL+?= =?utf-8?q?8kkazvk2aTJHtmB48Po9NOoiaZNmNEcWwASlaB1d3Fmz1rfLwUn96EoQ4Id9VUWIs?= =?utf-8?q?lYvMjki/qtyTGWe4oCbaUizFaZWcBOhNWJK5fVGgVTXgT2Z+o2ul3yfaiyGnvfPZ4?= =?utf-8?q?iE0zsZE7M0mdKEtYaGY9zB3nGPDgcODrVd3/bOo8g6WG8MAXLgFilrNVH9hdU/tzg?= =?utf-8?q?OvX5zbn+7qbmBVVPyv9sne/95qngCLMgapgZmIRkd4KOTwH2ygMe3Rqbd/rds7FwM?= =?utf-8?q?19ju3e4BpLgWSTC9a5m2mDSxV2E+xGbwia5yKETpV75tt1cPCSyOUQ95GqobaSGSq?= =?utf-8?q?KbhjNSH3NIr08oAUL3JJEKSlUD9qJKR96KZAV4Oq09B3TWd0ZfP0gPizKp83jjZ9J?= =?utf-8?q?Uxhykg+q8YsDAvxpbKjN4bmldYtfKupG4Fp93ouHbISbcL4fYcc64irj3JZeaga8M?= =?utf-8?q?DbqqTY4DY3YcOOm0oJnHvlat5GkGe0dlQ71QxTpN2X7hBcJrEUCQHaUxFCLJgtLqp?= =?utf-8?q?KzpWHTaf4w1OQHZYwMmXok2TcqWCCFiti7t41d5UdmfV7JVXTrojnsKLXDF0ya/Ix?= =?utf-8?q?FnylJHaL8C0chG/xPmevIDw2kb0km8UxPHhRzoW/dzVCbe71p+jRg87B7NVgHSUoi?= =?utf-8?q?vzqoTtpkxH3/EyZj8J1F5gQWkhgmcDHbsqt4tQpCsTWdMGu9yF+snDM9+qKSJfIcy?= =?utf-8?q?j68h9E3bbrK5jBScJz3od4RuqEnGOLAyB5xCSRbe3Dc6pandYiiJEb3SQuvSEArDl?= =?utf-8?q?Yn7WKui61FCZJ4uKmBLRckrKmITjn9oDhPuI/nUyIt71FBNfCjY87zFEL4ZeEiek/?= =?utf-8?q?DEON/ZwBRoCHAL/ped69BwPxGRWgZp2XNyb6Xupfrf4jkMqDH8mr41WknaOzqAneq?= =?utf-8?q?aATAs1XeX/Ik/88uiqaonw5a7mKZzZZgc1EU8P1ElZzo1lgPJH1e/+DKHcjtDIgTD?= =?utf-8?q?BcQMmC1Ndse9d2scMcX/o/QqM4/kGgELgROV/9Y19r1lwSY+YfnIRYuEmdSCKQlmO?= =?utf-8?q?BcTsoO1gWZYjZu0ngH6DBUDwVRwjQJQZlZBESdXaxJBHz2CDZSJZG7SvSl+nmCm+9?= =?utf-8?q?8r4hH32fOhhdVdc6IrK/x8/eRjoIwjEYuINTfxDhQEwgwWk3tOJ16SjREex8EalO1?= =?utf-8?q?8RFDGhghOmz53oNITnGLrs8OSUBcwaYOsHKhvwJ8Jq4ncMKRDwAB91w2nIlLBeQpx?= =?utf-8?q?O8fcDykC6Da+/IzwMMitVVN5EnEoBwpI+8zCOi96KX+ciszDXkPJIu9GQe/D5OfDN?= =?utf-8?q?1GSZZWD0eafRKzoW?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7988f48-3e17-4028-d6bf-08d97cd06436 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 07:21:12.7492 (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: +kS0cPmW0ktOELRYfFrSvLx3W8jO+myJKsOsj5Jca8mudtFhbJXABARVd5v4FUyQJOKhi1MKgUDXZYrYFEhTKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2606 To become independent of the sequence of mapping operations, permit "access" to accumulate for Dom0, noting that there's not going to be an introspection agent for it which this might interfere with. While e.g. ideally only ROM regions would get mapped with X set, getting there is quite a bit of work. Plus the use of p2m_access_* here is abusive in the first place. Signed-off-by: Jan Beulich --- v3: Move last in series, for being controversial. v2: Split off from original patch. Accumulate all of R, W, and X. --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1319,6 +1319,18 @@ static int set_typed_p2m_entry(struct do return -EPERM; } + /* + * Gross bodge, to go away again rather sooner than later: + * + * For MMIO allow access permissions to accumulate, but only for Dom0. + * Since set_identity_p2m_entry() and set_mmio_p2m_entry() differ in + * the way they specify "access", this will allow the ultimate result + * to be independent of the sequence of operations. + */ + if ( is_hardware_domain(d) && gfn_p2mt == p2m_mmio_direct && + access <= p2m_access_rwx && a <= p2m_access_rwx ) + access |= a; + if ( access == a ) { gfn_unlock(p2m, gfn, order);