From patchwork Mon Oct 2 15:11:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC8B9E784BC for ; Mon, 2 Oct 2023 15:12:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611611.951142 (Exim 4.92) (envelope-from ) id 1qnKaa-0001K5-Et; Mon, 02 Oct 2023 15:12:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611611.951142; Mon, 02 Oct 2023 15:12:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKaa-0001Jy-AF; Mon, 02 Oct 2023 15:12:04 +0000 Received: by outflank-mailman (input) for mailman id 611611; Mon, 02 Oct 2023 15:12:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKaY-0000iK-CI for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:02 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 08f340da-6136-11ee-98d2-6d05b1d4d9a1; Mon, 02 Oct 2023 17:12:01 +0200 (CEST) Received: from mail-dm6nam11lp2177.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.177]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:11:52 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by BY1PR03MB7261.namprd03.prod.outlook.com (2603:10b6:a03:526::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Mon, 2 Oct 2023 15:11:50 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:11:50 +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: 08f340da-6136-11ee-98d2-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259521; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=89MbL0AA6pA3j09tSq3RGefrgIUOeZgIRdfPXOZeMoQ=; b=fNwCJUxZJpTBtSlXMzbrvhaTiMDWFWgLY0eauyYRFL0xcfMkiZcV/hKX smYxAu4ndBnfA8IULRABVyW+68yw3cTyW9JI/Gy0PM2wG4qPMb7SLTDL4 j5CGXcLc0Xx/wxaAL7i90AO/ziiTNvL3dEb3gc5yOAtCbIRuDttFN/pEz 4=; X-CSE-ConnectionGUID: 8zczh8/BSZCOU1bS3+9qSw== X-CSE-MsgGUID: sXuusDf5S2ahrPxYFbt2kA== X-IronPort-RemoteIP: 104.47.57.177 X-IronPort-MID: 123016509 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: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T0EUMqyVMbEVt6fHCAnTKade/DGEmprY+9s3GR1WPHBXg6IL1XYINu6CeHcGPTWvnfACZe ehDswsnUvZRV0nKv6VK1MiROb5q9jChPvdEGI7705O0nj0sduwgoSKaSSl4g== X-Talos-CUID: 9a23:uiUQq2iuPK0dRwSV2fbqE7/omzJuIm/W3neAZGWDO01OdeSfcgTTqbpfjJ87 X-Talos-MUID: 9a23:Kso7RwSNqkqkvpGiRXT3tCx/L+tmvp/0AUAXqYU3lcOYby9ZbmI= X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="123016509" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lilj1/5dN+dgDy3LLIVwcnFp/soHhLmWTGnXbItjcHR9dZZfHYrajoXWn6K1UfBIBZl3rEhxwh3E2ZZaJCJPllHQ+IfwTu1Sv2GIpOXf3KOM5V+UC5/eGc0He5dw4r3VYlGgIklxFQhmjoG1U9qLH7ZBpNXvZ0qxUp1nbgGHypzrde9gBvFoZIfVS1xaRpeTYdMkNyeFY1sHYirJ0zK3VYnp/0P34HyRbZGCpff3IyAwq3CC/1603zRos8NVsuZ7L7E+NTTzupBnwyhlKGJ61BE7FH1ZOsJOad+5ivPAzRWANp9Qp07PWVE82Tgc6+9KY7nCaOowXwQg120uJwzGjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZCapLEs8x3+5/GTRGxm23TN+ireMD0Zi0vUFCTJ5I3w=; b=l7h3pI3JIvJiXdbeigx0e4H9hGp/8wxEaCAutFBjgXLIVAg31fSEcvg/e4BLPXhrOp4vmqfcP8te/y+9MapuaTTPpZtGytfrnrpKkYyPbi1lFWP/IBf7vP16akdg1Oos4k9XKdACSHnf2bNcVG/Zhaq/TU7HNtROiMqw4QOLok737SfSdv63usZhoBGzBXU7t6dZ1A4ssSEHM9bP8ANbaKJbF38YNask0bGtaS0kiI9TZHPaLZuAGqwczVDRkANV9Hi7TQH72wh07WY2LJqh+gVyJ/3PlYkm/oihADekZYK1oYbaVca01WJTfhOSmYYeR5Uoizno4+Hue1cCW846tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZCapLEs8x3+5/GTRGxm23TN+ireMD0Zi0vUFCTJ5I3w=; b=TTBoomylDiI/fZoE5pbgZ+A6AtXnIAM1f0y5I95S+WzR0V6q+CQT81tRutr52tW9a5BnzOIld3OZ9RXN9X4i0GupGkaFUWUlK2H+LbywoWkvg3NTiWDUWCclA1fAff72968IZWgj9jJ4QB9X7pHn/2uyPNTTViE0EayO1Y5DrAM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Roger Pau Monne , Tamas K Lengyel , Jan Beulich , Andrew Cooper , George Dunlap , Wei Liu Subject: [PATCH v5 01/10] mem_sharing/fork: do not attempt to populate vcpu_info page Date: Mon, 2 Oct 2023 17:11:18 +0200 Message-ID: <20231002151127.71020-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0394.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18f::21) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|BY1PR03MB7261:EE_ X-MS-Office365-Filtering-Correlation-Id: 652424a6-046c-4c49-46cd-08dbc359e6f9 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y7NaQNpjzivMG6j90Zl8dW4H/K9jcMDso9EbdxuyowDBovEM39UeSEnm+xLM4H+Yw4SnHrkrnvlcs32Z+xzCLXFCA08XCHSZJheI/Pqcfsog/uFCaqHzsZYueeNUETHcpNGen7fKZzStEFRQi1lWCtSYc3vQCIIBnV2kAcinEb7D3qF9xN8wl9d230H+Q/OWN1K89Kq39VKLtDrI4RBPgKIjqgF7MZt2zaw4n8EfCgZH9aNFYgEHErVlf3LxAWoFyNttO4zJjghkW/bcsKSgmdAzl9C0Lxcyx/8FuY9hc9h/z/9hnMT8VMCkXJ/pPoStQxvbXVnzTQJAtNIlmFu9gLP9g/q/r1dIJFAZQHm4op71M2CKEaXKSfRjOfwg/79zIfooEKqIZXQhJQtmUDn1I1vHtfwuk1PQbkRnqFkpupnZ4i4blZV7ph92GLfC0WrNLZ+CZ7W+Iiva88UQcHeAfwvv0xrpI6G0lCUQPCjCfzJzaSHOVNk29dco7iBW3CZiwR7YYItjXBXQOpqqj87UOxyzb3qtTagT1f99ATt6A9kpZ6ZWfGN8S8YPsb9A612M X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(346002)(376002)(136003)(396003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(4326008)(8676002)(5660300002)(8936002)(6512007)(478600001)(6666004)(6486002)(2906002)(6506007)(26005)(1076003)(83380400001)(2616005)(66476007)(66556008)(54906003)(316002)(36756003)(41300700001)(86362001)(82960400001)(38100700002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?h0iGuZ2CIHcWg+RoyYsblJKW2lnZ?= =?utf-8?q?CzxMG+cViTGHpqvAmfrnVhr+HXQk39CFNmLmeGkWJwrGAevNoe7jMjL6I8A2rxJFz?= =?utf-8?q?RL2BA+JsDeJ0A5Dn4s5lgaX3Ivc+vaYuSXrE3zJmIbHgMnWs9fM3nY/SY/cn5PI+/?= =?utf-8?q?VGRmmwJmU3O58Du7UcJzuLFKHhX9TF8oAu5YJNyqDlnySY/3ZbEjGJJBzr6ieNopC?= =?utf-8?q?R7Rmg/oq1EdO3uPKcuS4Mv+nfzsH/dVnYHKOKhq1d8cy+5Jv8N3Q71sJuryuiDqG5?= =?utf-8?q?tjM4T816TeqZjDXfCDaGLQn7rxG7+yiw2m0ymGb6ZTh69GMCiuCL3gl+nE0DA+eXF?= =?utf-8?q?JGX1aeqFW6hm8uN3ZgKtS12dUSMObygJ68tBdf8lQS0qqR9FLKqagiFKdHKN1YU9I?= =?utf-8?q?srhDQPty7VgRReF3saV9VP9rtav2/bHIyp3XRJ9i2fEc06ROc9SjxEtevbJkxpU9T?= =?utf-8?q?UmscYkmEOqS667QIgJxGmIUyfOFSYECYD1IacdMRzrqzeDm2zjwoX3YUYe5KsAnH0?= =?utf-8?q?mtfv1DfH11fMThCPO8aUvNJZEWjSupRcytqCBifjlAVPoenw2KPYNie21lBfkTrmP?= =?utf-8?q?BEFaScLqU4I0C5gXWpuLLbtf3WmnPe1NHkdpwUM0qqhWY5Bt3jrfSqYHaJuLq21sL?= =?utf-8?q?KCOFHQDWQ8dPdJvBVFpZXGC5RGOWTgm+SWHCJXiSSP5LGnW1VgJB7kD9WMC4OVoL3?= =?utf-8?q?H7r+IqXCWaToPbO17pWqj/xyVPtQ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op-MessageData-0: 0MemQD8/KLfsONCJ+T3kPjM+e5sVzpL1OWHXPAfiq5dDRywNSEIv4tWzriZ42c02JJh3EUyPrUYJiLQt2JKiBzvK69D70ycwOt9ZLmUzCH2Ohj6ndOyAuccRwsYoutCvFKK0Uhg0/kLiSnyHbnifZrJKX6UMmoRqzMOlcZ4ZsQRq10g778TrJermljOkmWX8umbjH8q6cJ3pQisWmrecvCszKm+XJiANEpvReJCCkFOcBSiB2gcI3t5oG+KZ4NyBTJR8n080y2QXUkbVPeKxEQS8EcpcbLNr0SLSLb1etUYmbl8Ql5wX+pUUjs6QgNpxG8wS9qalgU+jg86WR09mjnypzux350N17gVWGK8W/2A0nMm//o4LkHCDgT4xvdBSHycaAMnBASFv3PxyD8COp/vQHSfBRq3cW0ujUR6+es2rhIh1kjycN7WUf7dOn9O+z3Dx5EcSIKW2Ex34r+mIvZUx4DR588dMsBr03JpcYvmykY5PTPOGhW8a9rbljjYDbPAQRiGmXbHb5NL4evlBJ/3FyjtBviC1SiQqi8A1RAHIgr3FQp9Wyvsbd1IUrGg+LPh27d9MGrREZ8DMZu6S8KR/bKPYk/XpC9ofBF6OfEDBOVr8sSqfBLp37+6q/mTNCi6HmdGTuvdTx+ip2IxoMoThbHd9pUeXOo9CXXA4OwLci2H+eWrlbS61WgcOqbYrHXGp2DCDoOh1oZkhnKl0XqxNXNWty3E1P4w0UuKOSJ5rDhPHm0ChiFlhcvScsRniDq67lhqBfSqcKYZ3+iP50rDBgt36iOza7TrgYsOGsp36NaNKKEgKDOQvr5QttI4qdEsThNC9SbwJmn2uuPgpm8d0AqSMbgfWFnRxXHSRI+kfpFPGo6IjNTwqLOL62fSL X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 652424a6-046c-4c49-46cd-08dbc359e6f9 X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:11:50.0218 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hTBb32C7GRXYlmq9+USVN3xLKRzT3rl1vBZMqbxMtTQ6WZ3J+X3xLstaNGV8fI45dt6a0uzJZmv/4lz0quWzyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB7261 Instead let map_vcpu_info() and it's call to get_page_from_gfn() populate the page in the child as needed. Also remove the bogus copy_domain_page(): should be placed before the call to map_vcpu_info(), as the later can update the contents of the vcpu_info page. Note that this eliminates a bug in copy_vcpu_settings(): The function did allocate a new page regardless of the GFN already having a mapping, thus in particular breaking the case of two vCPU-s having their info areas on the same page. Fixes: 41548c5472a3 ('mem_sharing: VM forking') Signed-off-by: Roger Pau Monné Acked-by: Tamas K Lengyel --- Only build tested. --- Changes since v4: - New in this version. --- xen/arch/x86/mm/mem_sharing.c | 36 ++++++----------------------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index ae5366d4476e..5f8f1fb4d871 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1689,48 +1689,24 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d) unsigned int i; struct p2m_domain *p2m = p2m_get_hostp2m(cd); int ret = -EINVAL; + mfn_t vcpu_info_mfn; for ( i = 0; i < cd->max_vcpus; i++ ) { struct vcpu *d_vcpu = d->vcpu[i]; struct vcpu *cd_vcpu = cd->vcpu[i]; - mfn_t vcpu_info_mfn; if ( !d_vcpu || !cd_vcpu ) continue; - /* Copy & map in the vcpu_info page if the guest uses one */ + /* Map in the vcpu_info page if the guest uses one */ vcpu_info_mfn = d_vcpu->vcpu_info_mfn; if ( !mfn_eq(vcpu_info_mfn, INVALID_MFN) ) { - mfn_t new_vcpu_info_mfn = cd_vcpu->vcpu_info_mfn; - - /* Allocate & map the page for it if it hasn't been already */ - if ( mfn_eq(new_vcpu_info_mfn, INVALID_MFN) ) - { - gfn_t gfn = mfn_to_gfn(d, vcpu_info_mfn); - unsigned long gfn_l = gfn_x(gfn); - struct page_info *page; - - if ( !(page = alloc_domheap_page(cd, 0)) ) - return -ENOMEM; - - new_vcpu_info_mfn = page_to_mfn(page); - set_gpfn_from_mfn(mfn_x(new_vcpu_info_mfn), gfn_l); - - ret = p2m->set_entry(p2m, gfn, new_vcpu_info_mfn, - PAGE_ORDER_4K, p2m_ram_rw, - p2m->default_access, -1); - if ( ret ) - return ret; - - ret = map_vcpu_info(cd_vcpu, gfn_l, - PAGE_OFFSET(d_vcpu->vcpu_info)); - if ( ret ) - return ret; - } - - copy_domain_page(new_vcpu_info_mfn, vcpu_info_mfn); + ret = map_vcpu_info(cd_vcpu, mfn_to_gfn(d, vcpu_info_mfn), + PAGE_OFFSET(d_vcpu->vcpu_info)); + if ( ret ) + return ret; } ret = copy_vpmu(d_vcpu, cd_vcpu); From patchwork Mon Oct 2 15:11:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406334 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CDFFE784BC for ; Mon, 2 Oct 2023 15:12:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611610.951132 (Exim 4.92) (envelope-from ) id 1qnKaX-0000zB-2f; Mon, 02 Oct 2023 15:12:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611610.951132; Mon, 02 Oct 2023 15:12:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKaW-0000z2-VK; Mon, 02 Oct 2023 15:12:00 +0000 Received: by outflank-mailman (input) for mailman id 611610; Mon, 02 Oct 2023 15:11:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKaV-0000iK-Oo for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:11:59 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 08208163-6136-11ee-98d2-6d05b1d4d9a1; Mon, 02 Oct 2023 17:11:59 +0200 (CEST) Received: from mail-dm6nam11lp2171.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.171]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:11:57 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by BY1PR03MB7261.namprd03.prod.outlook.com (2603:10b6:a03:526::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Mon, 2 Oct 2023 15:11:55 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:11:55 +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: 08208163-6136-11ee-98d2-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259519; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=/cORn2PaiHqMpwBU7PffBoZFBHMZRIJY7zh8CAxkC2o=; b=Po2UMz+bFpp6MJv/09Lu/+B6waBsNspEeVTHnZCDz+OGCvoP9TSE9WEK Hh42oP5ThC6ECSgDv58PAUeAtCEOckpjhUkGo1+eSMPTHFVGD+GvHP6bw xaQWncqQ5vaPtuSgqtMNkPdZBhZ8bfpUncMThd8lXReYDb7yrvdoVdUp3 w=; X-CSE-ConnectionGUID: Y7rpxt7YSRS3iVDgHE1zQg== X-CSE-MsgGUID: V+5MSSPsSUKH6HupM4hYyg== X-IronPort-RemoteIP: 104.47.57.171 X-IronPort-MID: 123653196 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:8TnVnaiAEbhhYJevwu59SV1rX161UhEKZh0ujC45NGQN5FlHY01je htvX26BOa2JYDTyf49xa4vko0kFuMfVztVgTAtr/Cs3QyMb9cadCdqndUqhZCn6wu8v7q5Ex 55HNoSfdpBcolv0/ErF3m3J9CEkvU2wbuOhTraCYmYoHVMMpB4J0XpLg/Q+jpNjne+3CgaMv cKai8DEMRqu1iUc3lg8sspvkzsx+qyp0N8klgZmP6sS5AeEzyB94K83fsldEVOpGuG4IcbiL wrz5OnR1n/U+R4rFuSknt7TGqHdauePVeQmoiM+t5mK2nCulARrukoIHKN0hXNsoyeIh7hMJ OBl7vRcf+uL0prkw4zxWzEAe8130DYvFLXveRBTuuTLp6HKnueFL1yDwyjaMKVBktubD12i+ tQpdyoVfgzcttmM++m6dMVjpul6PvDkadZ3VnFIlVk1DN4AaLWaGuDmwIEd2z09wMdTAfzZe swVLyJ1awjNaAFOPVFRD48imOCvhT/0dDgwRFC9/PJrpTSMilEuluGyabI5efTTLSlRtlyfq W/cuXzwHzkRNcCFyCrD+XWp7gPKtXqhA9xPT+TpqJaGhnWthTE2MyYuTmCGgtnnqlOmfo5fG l0br39GQa8asRbDosPGdw21pjuIswARX/JUEvYm80edx6zM+QGbC2MYCDlbZ7QOtMIwXy1sy VaPkPvgHzkpu7qQIVqf/LqJqTK5OQAOMHQPIyQDSGMt/N3LsIw1yBXVQb5e/LWdi9T0HXT8x m6MpS1n3rEL15dUjuO84EzNhC+qqt7RVAkp6w7LX2WjqARkeIqiYI/u4l/ehRpdELukopC6l CBss6CjAComVPlhSATlrD0xIYyU IronPort-HdrOrdr: A9a23:lnW5YqlK8d23J/uohQM/nNdh27fpDfLa3DAbv31ZSRFFG/Fw9/ rCoB3U73/JYVcqKRcdcLW7UpVoLkmyyXcY2+cs1PKZLWvbUQiTXeZfBOnZsl7d8kTFn4Yw6U 4jSdkaNDSZNzNHZK3BkW2F+rgboeVu8MqT9JjjJ3UGd3AVV0m3hT0JezpyESdNNXl77YJSLu vk2iLezQDQBEj+aK6AdwE4dtmGnfLnvrT8byULAhY2gTP+8Q9BuNbBYmOlNg51aUI0/Ysf X-Talos-CUID: 9a23:r400OmlTKfEhrQy+dfoOH7jmSYjXOUyC1m/APxCJMlxSE7yrZVCw1fp2qsU7zg== X-Talos-MUID: 9a23:wUkaqAowi39wHDPz3A4ezw8haeJT2Jy1M30uscsmptGhaSxBKjjI2Q== X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="123653196" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dX0LlBbrKw93fSZJ3C3CRrVKFzifI13yNHHqojUJlW8Zx3AfkzEKJE4R4/zMlx2h9UTIgx26n34S5DYyRajc5ubIEU8dMf9z6sOcChweydj8MBtq7Sy0NwmDreaATBiYdbOWwzm5BKuBw4lS6I3sBFA5elY/OIyn2b1Khxqs7QR0IG1tPAV/EkpkjHvVNuhZ+t9Rjw0BloQrjj/+oKbpvaaMdalrKcaM7O1qJSr1TYKhlhNTLEUMsj85P3d0Im8ek/zBD7ZY1XoR/j+k6dXLShySg1hVA/cd8yGB1To6RUUlhGICJVI+WbTLTgDZ4WUPUfGazHIm+gLse1qHVil/Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=01vEMBP+AIsrC5NQCk+WSSYp1tHvGShg3O7HS4rvvmM=; b=ZdBgjig6tiAgD3a86CEFS52LshXs2fivotR/NV+NNC8UbW0FcaLtqwvDwQjzYWvu85PeoHyqvcfIl0xokJLGckGQPD5YgbfG/t9lghxndm3U9Aj2lodGJcGvrcQxNBkY/Zs/c3914+qxG5lUXyHhYSJTnjLi3dS8w5E5pJs3PhrDYR8FFWR10FLt2/2vghEmt/J1AscWiuF3ZjqKVXk7f9g0tlguidAtkyVcEAiJiWVFHZh6JEMp1Vd5ofvBr7yG9CM2u5ZjcnxkLbK9dyxdrZlHBk6u/1EwgjZusQmFsPTYpqiR3U23GK6oZfg7lMrw3Sl6n/d/lBp8p2/Atg48MQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=01vEMBP+AIsrC5NQCk+WSSYp1tHvGShg3O7HS4rvvmM=; b=SjkaX7Lj8UR5uoGKn1Qm4nAkZZT2zPMpsHUkqkOh20jfNXOtIrj8uvi7zqYL/10WQlx8lbfwQQA5lvz/Q0B9fTm1f+alHuiz9EDTdxpvCUDe2PeKVjZT9zvZ20JywfsRhjKWo1wBIxq+krOAkxL1MGWmHYwCuwXDwUutUq0ahTY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH v5 02/10] x86/shim: zap runstate and time area handles during shutdown Date: Mon, 2 Oct 2023 17:11:19 +0200 Message-ID: <20231002151127.71020-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO2P265CA0204.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9e::24) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|BY1PR03MB7261:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f7eafb3-d170-4dcb-f46b-08dbc359ea7b X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xLtdMGHdWUeCyT+p3z0DXHKBwkadepLJhvWXg6GJNiI9yjxhqiVJuY4gB4fH/Kxxd4792vMAnISW7ZkAWZzTk5HuCPc3SnotQNouudVU1DZNSUkDxZhTJdubY6AYjR1IBCEUNTbUtq5T4g8Ggiwj3lxoYCbyrhlAeHKHkolDustJ0j1NYhl8Z7p3EYpWm+b8yaj2RSrvISY61Rfpd2dIAamX/vJYdwoDA4BNZZEeOTN4+BaqyEBZXxw2hAC9A8n/0iaxau7ONDJjUSjoYKy9YpkypsM/WFBW6W4rD9b0IxM84gt/86vv57OcZWqCpYnnwm+dKrpWQWIOeZLiRhBsw5O5pokWO5iQwbzqc9fXc8OPSELNIybrLFJTs+DbyJejMDbi2sFi2M4Df+PoGGA1UdOsB0KreWvRRdxZ03RsFmxg6fXrakLmcoDCgBD1gfqya/LEjaCx97FK8UdbVmnNoLRIxYoO2I4KXAvZF+jRzIEzOCPr/1basJWZoXx4dxM6c/xsx/4mcI5LrV61m0PJFXlYD33RlgQZ6Ku9X9onRwrTFqFS2jqnFrtRFs8/2EaB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(346002)(376002)(136003)(396003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(4744005)(4326008)(8676002)(5660300002)(8936002)(6512007)(478600001)(6666004)(6486002)(2906002)(6506007)(26005)(1076003)(83380400001)(2616005)(66476007)(66556008)(54906003)(316002)(36756003)(41300700001)(86362001)(82960400001)(38100700002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OhAMHU6ARxhNq11kUflyUOBdRtJT?= =?utf-8?q?sQ8+cRxcmnpN9stwN2DO7PUl40DmPJl3UjpaefyYGq+snRa6Pdzu1um+WJI5q12s3?= =?utf-8?q?zAzuzUURCwSi00M4BjFdIl9+mWohDJPc2EMQlo8UHcBSqYYEl/KpkUtLuodk5P1lU?= =?utf-8?q?b69jX8Fowo46ZA5seNtWliw4mGNvFZcQeKERho2e9GCED5oB52CW7eZn1yQJO7xG+?= =?utf-8?q?x4qSJhVlZE6dyh9Z0VVa+U6KtN28XIbbaG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ge9r82Q1HVxhdBuVPMsOHD2vbWWe5GMm7d4Ej64NLx9bLdci222+VjSHGtF7eaJNN3BHJlh3hxFBaxH27OvD/AVuWHbTYsmOLMQqD6k4eXZevT2rt6zLMA564j6M3HeCJojZU0GJCy/6ry2k4Ochn9eU07FHe3D+psh54y1YjOfqpi5JVONvzfh8nQtbTnkNQv/9cFIS+tpxCYJLWqdRAQujBJHmUdgF8dz0d5dW4/GgEcLqTtmR9EsKefzJRH79v5IvpZ9jhctMEpJMWag4gFWItSqi5B7I/JIk2+D79hwMYpwq/87Fv3zFG43NrwQHBfdKWlVo24oGuT2yWjZ1uAoIA+YCRYdXmKSP9nrNnJwWbChVgXI9/TcFQ== X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f7eafb3-d170-4dcb-f46b-08dbc359ea7b X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:11:55.7373 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S0/yRhcGJdUJILt00Z9c3U1sOrPuZKQeW1vGRb5DpHZUgM0DZRuIuJlf4Du0jwX8rdI4XaBgphb35/Xnjps9eQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB7261 From: Jan Beulich While likely the guest would just re-register the same areas after a possible resume, let's not take this for granted and avoid the risk of otherwise corrupting guest memory. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- xen/arch/x86/pv/shim.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index ca0e639db323..7e4bacf7ae40 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -385,6 +385,10 @@ int pv_shim_shutdown(uint8_t reason) /* Unmap guest vcpu_info pages. */ unmap_vcpu_info(v); + /* Zap runstate and time area handles. */ + set_xen_guest_handle(runstate_guest(v), NULL); + set_xen_guest_handle(v->arch.time_info_guest, NULL); + /* Reset the periodic timer to the default value. */ vcpu_set_periodic_timer(v, MILLISECS(10)); /* Stop the singleshot timer. */ From patchwork Mon Oct 2 15:11:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 196D5E784BB for ; Mon, 2 Oct 2023 15:12:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611612.951152 (Exim 4.92) (envelope-from ) id 1qnKaj-0001xv-NY; Mon, 02 Oct 2023 15:12:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611612.951152; Mon, 02 Oct 2023 15:12:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKaj-0001xo-JM; Mon, 02 Oct 2023 15:12:13 +0000 Received: by outflank-mailman (input) for mailman id 611612; Mon, 02 Oct 2023 15:12:12 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKai-0000iK-K0 for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:12 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0f0f17f0-6136-11ee-98d2-6d05b1d4d9a1; Mon, 02 Oct 2023 17:12:11 +0200 (CEST) Received: from mail-dm6nam11lp2174.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.174]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:12:04 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by BY1PR03MB7261.namprd03.prod.outlook.com (2603:10b6:a03:526::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Mon, 2 Oct 2023 15:12:02 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:12:02 +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: 0f0f17f0-6136-11ee-98d2-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259531; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=6gHhxFy+J8280ZMPe8YdCojqqUzWecDthtEiavpBLrU=; b=Y59ob4G16EYbHfvqLg+yIAJef5XjO92f/oHqF6Q7xdfvnuJ+Oh9ZmHan Gzu5kXxFNStrOfX6Vjb3SXjYuK74Zcymqc9KJjHGds6QLBil/O7nghUF5 ca5L6YhUv4FwVSzd89t5NmJCj6/BvQRH8tyRspeoDj+3fINrIG60JY8X1 I=; X-CSE-ConnectionGUID: vwv/yUlCSAChbpnQdCPfaA== X-CSE-MsgGUID: it33cAXiTQ2FyjIh9QvMYA== X-IronPort-RemoteIP: 104.47.57.174 X-IronPort-MID: 127150636 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:SnCLT6pNW2KxtPo+gMuvVi/OXF9eBmLvZBIvgKrLsJaIsI4StFCzt garIBnXbveON2X3eI90at7lpB8Ev5SDnIAxTwVvqiA8QykQ9puZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbOCYmYpA1Y8FE/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GhwUmAWP6gR5waGzyNNVfrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAC4ScFeSuuad+5uQSuN0gP0vB/HlNapK7xmMzRmBZRonabbqZvyToPN9gnI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeeraYWJEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdhNTeDgqKU06LGV7m0PU0YdfGu6ncDjpF+8etIOE lIxywN7+MDe82TuFLERRSaQsHOC+xIRRddUO+k78x2WjLrZ5R6DAWoJRSIHb8Yp3Oc2SDowx xmWltXmLTV1tfueTnf13rWeoC62OCMVBXQffiJCRgwAi/H8pKkjgxSJScxseIa3k9n0FDfY0 z2M6i8kiN07ltUX3q+2+VTGhTOEpZXTSAMxoALNUQqN7AxjbYqhT4Wt4Erc67BLK4Pxc7Wal H0Nmszb4OVQC5iIzXWJWL9UQ+3v4OuZOjrBh1IpB4Mm6zmm53+ke8ZX/S16I0BqdM0DfFcFf XPuhO+Y37cLVFPCUEO9S9vZ5xgCpUQ4KenYaw== IronPort-HdrOrdr: A9a23:x8Rm563EYxJwQqK48Jpq2gqjBLYkLtp133Aq2lEZdPU1SKClfq WV98jzuiWatN98Yh8dcLK7WJVoMEm8yXcd2+B4V9qftWLdyQiVxe9ZnO/f6gylNyri9vNMkY dMGpIOb+EY1GIK7/oSNjPIduod/A== X-Talos-CUID: 9a23:t2NXu2olz6tktoaObBqAaMnmUd46bDrM8XP7GGaTCWxxToSZYmee8Yoxxg== X-Talos-MUID: 9a23:tn60sQ/c0GPDktsl+S3FFlSQf8Z0uP+lIXAMraxcldiGFCwhAim4vR3iFw== X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="127150636" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JjL+MVsLPPengiOIOnasL8CE/lGTyGQE/wjz2pqvGx772wKtMEHtX+StBgpCsyXvqJd4NZJk/MOsNIQFLPofvAdChEzpnHkKCuFLl9Crl858Vu8rDsZGDL+rW/r8OrchBHJtA7VYsW3w8D7UsGUwyjcI1qI/c5HUMaGfY4RMnD/gWe3Ygi5WYRdTYCY4WSC3e1sOTJaIkX82sjQKxLbZyhplzZFs7/Q8UgmYCvP7uoLweny3/k72xtf5XkS29QJk7UW+FSgxHs/vip8dx/33wn7wjQ2TMN2RbOLApWrXcZqwt82aOq6gRDhXW1PnQCGJX9C/Y8Vj+U4XuCIKrbc35Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t0a+M4UUU+XHTQe2PaZicm+9CI7a7rFkdkSd/BDJVyU=; b=Bs6UGNs7pkwIc9mdtd68DosxabGM8Zv9JBKhZaAP4YT/uSga/PtdlE8lAFBigVNRaOUBwjRhXVZqekIuIoI0bCfa0UM71c5nX24gzeVpYJjXWQ1m4GHyw/zCn/bQYkp0OqBzMR6GDt3ACCpfH1D3xDSAfNFppjuJ4olUgdRlEEcgsuA9HdsjWouoZ7Zm0Y6m8zZUm+Z5uEoWlZ0ynsEeLEQEYLHhvjAR8svZcMh4tfCR8adPnsbEaWsCLXjVBpUYtk+W2UQbHW6VHiRZXcoCtqeDj1nwi8zjqb+/PlxPhPRy1oYEUnw0O/FIuI2s/moUrMzGmlipNg1aMJaZ7kyYtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t0a+M4UUU+XHTQe2PaZicm+9CI7a7rFkdkSd/BDJVyU=; b=J7CENvX5CvT4seag4bMLif0sdYaNa/XMUUMh0X3oHafI5aEtF4oESkqTwNMydwg78EbgSJ265dAMvpGEtQrwSe+LTb1jlPfzXvZvBeRhMnUJWPTU5O8HHElDXVMcUtHqPVrHYhQTTRYhWGHJWQdH1SqzpU4iiZKAn5Ukn2sW1Pk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini , Julien Grall Subject: [PATCH v5 03/10] domain: GADDR based shared guest area registration alternative - teardown Date: Mon, 2 Oct 2023 17:11:20 +0200 Message-ID: <20231002151127.71020-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P265CA0057.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2af::14) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|BY1PR03MB7261:EE_ X-MS-Office365-Filtering-Correlation-Id: 38be95c2-ebbe-4ce0-ef56-08dbc359ee0c X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q5IIaaKWvl1P4qfTeIXDxiToucbhAN4CPKbvvwn0fMRamBr7CdV0b52axDJDov1mPrR0rGrBaWSzhGXja3RDgDI7JJNwSsOz2mdt4Y9vEJuGNZAhBwCr9O54OnhS9I11TIdUY/iscDU76Zt9qz2WutCpMMHlxfzqu/zCJj/NVwv0L3zd46KvC1+T6LnY8F+/okGCsQ3rA6Ov7g3ynujhsALABVHXGTW50vxW2+KZHmfcj46Od6kxBdr+9ETbA4KpPgSyy+3nrpMvFajnrf4q/6aqDDF596ikQGgjNd/tiHrs2KZYnCsUTeBjFRVJXO2cgIqdckZEWaE6qWQdUvv1BIOb37PnUABcMJvr6gbpECU3lHZMSNWljRMvd6qku02R9p4hXAyHMKGW0neH9oW+n5Pe+Y1lmHrv8WIA2KZ5tx/Udvq13uNCpmjeMTZ1jyJRdIXHfsoqzJnTHoqm5MjabY2kbxUYpLPsIC1oXWsVsozOBithn5POfCKh5slO+wwKahAdhY2Mhy6yyINgRsDldWhIwjVH4u3ein5W5hMcTW2+Yz3BpMRaUK1gGXz52rLR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(346002)(376002)(136003)(396003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(4326008)(8676002)(5660300002)(8936002)(6512007)(7416002)(478600001)(6666004)(6486002)(2906002)(6506007)(26005)(1076003)(83380400001)(2616005)(66476007)(66556008)(54906003)(316002)(36756003)(41300700001)(86362001)(82960400001)(38100700002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?dB2xnj9v6UGvFwThYuZaid9+zHNt?= =?utf-8?q?AgxllWIbuEA3eUf8mits8dpLrLEW35VMI5zHcsQzIdvmH1J57OAikTsfUd1WDiNci?= =?utf-8?q?iCnrJlHOnMEyPasnnl23RmjSqyTi8V/F3E7Fge4EnBiLbm8ZS/vMcsQpgmikaR6rU?= =?utf-8?q?JrWr813yPx9MQ3huRq8w3OVf9n6ze2kFeKH+Pm0VwYazGgeY8ohwp0os0SCfcMijy?= =?utf-8?q?VNID6tJsMlUVTw+zrc7oSyLP6KmORRGt0Tslhma6cw2sUfc4HjKDwfru/INcRQ93n?= =?utf-8?q?20/+Ur18GvkgBONnH3+j3w3YIAd1y1ijKTonnz5FWrzcLC0/e7GrS1P985P+XK0xj?= =?utf-8?q?SIO4FJe0kg/O3mUhim3w7qoUDpngzQwSGOdokrqrCpHIdMlBPOJNwkSUlagY7mLKZ?= =?utf-8?q?yywQSbIvO7uoWZhaX8P51F0EX09EdB+bI39ed5QtYZ64CtG8rJJx0wXG25C/p5I7X?= =?utf-8?q?e6MHicxx/L4OsI3c14z+PKyCJHhYNH0ZL2GAGMRvKoRQSrWTyj5wK7uhB0unAIj3F?= =?utf-8?q?EbZhcYmAvz07i3j9IL9u1wwBek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slw1KHoL1wpTOkX7UCfZSoOFAXuRyY6ZH6V1OdQXhQ7G3Qc8xItZmfZuN9ih4JbtKazPJ3glGXpSXSItxsh8H7FssnO76X4A== X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38be95c2-ebbe-4ce0-ef56-08dbc359ee0c X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:12:02.0675 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eQC5AlwV2Yj4mpkgh8W/837aFeWHPvCLpeAxy8EVwUWnSYBFv122Y6qTisJCUNOkaz9615DThZT5parXoV7RJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB7261 From: Jan Beulich In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary domain cleanup hooks. Signed-off-by: Jan Beulich Reviewed-by: Julien Grall Acked-by: Roger Pau Monné --- xen/arch/x86/domain.c | 5 +++++ xen/arch/x86/include/asm/domain.h | 1 + xen/arch/x86/pv/shim.c | 4 +++- xen/common/domain.c | 17 +++++++++++++++++ xen/include/xen/domain.h | 11 +++++++++++ xen/include/xen/sched.h | 1 + 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 645675d87d9d..9d352defa25e 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1024,7 +1024,10 @@ int arch_domain_soft_reset(struct domain *d) } for_each_vcpu ( d, v ) + { set_xen_guest_handle(v->arch.time_info_guest, NULL); + unmap_guest_area(v, &v->arch.time_guest_area); + } exit_put_gfn: put_gfn(d, gfn_x(gfn)); @@ -2381,6 +2384,8 @@ int domain_relinquish_resources(struct domain *d) if ( ret ) return ret; + unmap_guest_area(v, &v->arch.time_guest_area); + vpmu_destroy(v); } diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index c2d9fc333be5..e0bd28e424e0 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -669,6 +669,7 @@ struct arch_vcpu /* A secondary copy of the vcpu time info. */ XEN_GUEST_HANDLE(vcpu_time_info_t) time_info_guest; + struct guest_area time_guest_area; struct arch_vm_event *vm_event; diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 7e4bacf7ae40..f08b16bae2fe 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -382,8 +382,10 @@ int pv_shim_shutdown(uint8_t reason) for_each_vcpu ( d, v ) { - /* Unmap guest vcpu_info pages. */ + /* Unmap guest vcpu_info page and runstate/time areas. */ unmap_vcpu_info(v); + unmap_guest_area(v, &v->runstate_guest_area); + unmap_guest_area(v, &v->arch.time_guest_area); /* Zap runstate and time area handles. */ set_xen_guest_handle(runstate_guest(v), NULL); diff --git a/xen/common/domain.c b/xen/common/domain.c index 304aa04fa6cb..76a4c2072e10 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -992,7 +992,10 @@ int domain_kill(struct domain *d) if ( cpupool_move_domain(d, cpupool0) ) return -ERESTART; for_each_vcpu ( d, v ) + { unmap_vcpu_info(v); + unmap_guest_area(v, &v->runstate_guest_area); + } d->is_dying = DOMDYING_dead; /* Mem event cleanup has to go here because the rings * have to be put before we call put_domain. */ @@ -1446,6 +1449,7 @@ int domain_soft_reset(struct domain *d, bool resuming) { set_xen_guest_handle(runstate_guest(v), NULL); unmap_vcpu_info(v); + unmap_guest_area(v, &v->runstate_guest_area); } rc = arch_domain_soft_reset(d); @@ -1597,6 +1601,19 @@ void unmap_vcpu_info(struct vcpu *v) put_page_and_type(mfn_to_page(mfn)); } +/* + * This is only intended to be used for domain cleanup (or more generally only + * with at least the respective vCPU, if it's not the current one, reliably + * paused). + */ +void unmap_guest_area(struct vcpu *v, struct guest_area *area) +{ + struct domain *d = v->domain; + + if ( v != current ) + ASSERT(atomic_read(&v->pause_count) | atomic_read(&d->pause_count)); +} + int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) { struct vcpu_guest_context *ctxt; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 81fb05a64275..a6b22fa2cac8 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -5,6 +5,12 @@ #include #include + +struct guest_area { + struct page_info *pg; + void *map; +}; + #include #include @@ -77,6 +83,11 @@ void arch_vcpu_destroy(struct vcpu *v); int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned int offset); void unmap_vcpu_info(struct vcpu *v); +int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size, + struct guest_area *area, + void (*populate)(void *dst, struct vcpu *v)); +void unmap_guest_area(struct vcpu *v, struct guest_area *area); + struct xen_domctl_createdomain; int arch_domain_create(struct domain *d, struct xen_domctl_createdomain *config, diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index d8c8dd85a67d..f30f3b0ebeab 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -203,6 +203,7 @@ struct vcpu XEN_GUEST_HANDLE(vcpu_runstate_info_compat_t) compat; } runstate_guest; /* guest address */ #endif + struct guest_area runstate_guest_area; unsigned int new_state; /* Has the FPU been initialised? */ From patchwork Mon Oct 2 15:11:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A4B7E784BD for ; Mon, 2 Oct 2023 15:12:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611614.951162 (Exim 4.92) (envelope-from ) id 1qnKam-0002G8-3E; Mon, 02 Oct 2023 15:12:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611614.951162; Mon, 02 Oct 2023 15:12:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKal-0002G1-VV; Mon, 02 Oct 2023 15:12:15 +0000 Received: by outflank-mailman (input) for mailman id 611614; Mon, 02 Oct 2023 15:12:15 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKak-0000iK-Ts for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:15 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 103a8b3f-6136-11ee-98d2-6d05b1d4d9a1; Mon, 02 Oct 2023 17:12:13 +0200 (CEST) Received: from mail-dm6nam11lp2170.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.170]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:12:10 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by BY1PR03MB7261.namprd03.prod.outlook.com (2603:10b6:a03:526::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Mon, 2 Oct 2023 15:12:07 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:12: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: 103a8b3f-6136-11ee-98d2-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259533; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=pNYDrez4yWL8SFtgFmNWAEo5Kdu51z1s3+A+lxN5AXA=; b=IIM0FwDv/i951XMhmPBRPQLZkwxrWvw8+MoLOhqq9KjmRuxCb8Hhe/vz gVadLjB62NLZO1nSAtjWLOyScI8IEytnFM+VkqFMogtjrtWKN8CT7x+bo niXsid1eClir2K7RFtEe2PLAkqWFROjpslFxXNzqQTek8OQcCyP8HFjt6 M=; X-CSE-ConnectionGUID: vHwUt8gsRVKSw/zbV7Fkzw== X-CSE-MsgGUID: cN34MJP0Qg2FvJ3Ynkek4g== X-IronPort-RemoteIP: 104.47.57.170 X-IronPort-MID: 124816976 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:qv5rd6BeKLXiiBVW/97iw5YqxClBgxIJ4kV8jS/XYbTApDongz0Cx jQbDW6BOK7fZzP9e9l2aI+y8x4CvsOBx9JqQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48D8kk/nOH+KgYAL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ldembh12ODqe0DviFw== X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="124816976" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Un6Ea+ZZWP8TXe+RIm+H/mvs6bU8JCsdkppb+w3vS3YyhtNpfqkBXzLCac03thqvPYWdbKm+eKjyGd7Q/vuI/YICRkTjjP++0UI+j5E5PoZvx97ZseeWkzQUmlX/Dx2+OEwRO4OefCSzFLyC0uEs0q4vnkS1ayXe0SQ5AgUFGXfPaUDuNmCOaZneLzrMpKJttqDdMOOR7Q9jgqOFHCMXb2zRRxvWpAiMqNjY2hypwCJRxXHzps+6OEVVuLtj+MGDNJZqf+w+3qDlR3hFzWLPM/W2Cx5J7YrId9At0InkHhDPFFWnfTABuOcPgTaqXUKKEAjPnjrpKLXmWxuDAZgvzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sqQYB5GprqLA6zNhgwV+4qSeIntPqXWXOOafhMdSkF4=; b=XUhBx5jMh1BJPB+0WTjXYUFwzM0C+hl6CdLbT7ceo91W+eMd9JTSzp3EAFOWafErb2FcprhjXV8kLYCL9mr4CBrOGyI+blmAFRH4aMEq8Ir/nvRbTMjlNw2gIRTRYzpm5ZW94UQx4CBqOAyjGPjBP/3dsHCHBNTgEAhhLIhiAs5U5WQASK96a0aEOrIh44B3HeMNGvSTd9zhtbIKuGgsLMw9sdKe7be1qfgEWzU9gAdTHr6h1nkM44ULlfzPnbTeBTVuo46XCniRjGwCFFJwh0MonSG/kRmSTRBACcVrfiZQR2dqhuQX/pts4KepUklgoKQDiCKj4S/y0RZKkvfTpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sqQYB5GprqLA6zNhgwV+4qSeIntPqXWXOOafhMdSkF4=; b=SOCy4+v0XMwTvVWRIsJR1jhJ3+mc8dJAm5jcL47zYnIJvJ3Q94/+QmulFq/M9ymv148mLQl3yc0msOuWskBSEcod5g4qMg9fgEBxqjOv7xwPzWIGX65+XDWriQsb98vH7iBgHWZRCK/4lUtmW6kPRQjmjQs/Bv+zdebuQBkzpwE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall Subject: [PATCH v5 04/10] domain: update GADDR based runstate guest area Date: Mon, 2 Oct 2023 17:11:21 +0200 Message-ID: <20231002151127.71020-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0679.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:351::12) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|BY1PR03MB7261:EE_ X-MS-Office365-Filtering-Correlation-Id: 22aa39ee-72e6-4dcc-f001-08dbc359f15f X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DmvnGK0WlALcSSf2igdz6yE1pPOFvUEpk5mTul6FpBoi/tcU+x6BD9/IKc4zB5fo+NG5g+rGEUiIOo1EQDB/OvCaaQsqXnis/QcUY1LAHFmLnlf7iVyp2ItODkZoE0010Eoo7khIRUao//Uug9DRLusmjBlIZU1B9eF+XXISZfnlFcxlJtDJ4pBp6gMGniYkFY9H5hEiB9XXmXrH2pg9nMH0wmPU+V7k2GJsuuErcxPxel2Ts3NPHkmmPlLz/iB2bAvy/Zdf/+H6xtpD7jpC6ZwJrQvLm4qguN9Dt7Vae/UTUEb28ojiale2yWkWsgpXQrbhCEo54wjMNGs9T61vnDrRBVYeuw4GjTPEd24jSKp8hQEkeLimPfidfToGzRmhPgzxq+FVHEba3Rzg+hTCn6N0zG3D2svFY83/5SfNbXp6MwpnJXFnD5Nn4MVqFWKa8D61GIrcdT80T+8jHt8x9JQyNq2C1epnjSCq978Ua7nA42QMrQ3EBo1S1KGtElIm2BP9vPJQh0yoFi/K2C9DhJ9NjqpVCzmNIcMi6U5mZ/s2yUeOfmp4dZKyHYzY3T9H X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(346002)(376002)(136003)(396003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(4326008)(8676002)(5660300002)(8936002)(6512007)(7416002)(478600001)(6666004)(6486002)(2906002)(15650500001)(6506007)(26005)(1076003)(83380400001)(2616005)(66476007)(66556008)(54906003)(316002)(36756003)(41300700001)(86362001)(82960400001)(38100700002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?37ejyG6afbuiCpvx+hGctO7koOvD?= =?utf-8?q?sfrd4PoDhof9Oq4T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cbNw1xxdYXmIOGdfGhUsza8liPwHTqIsI7loVi+z4B8dx?= =?utf-8?q?TBBj3QtFpAe7Woqp8zuudjgJbZcJmIDnMqpz09R0yy+Gocz9TaGbvQke64wAs05E+?= =?utf-8?q?1aQKgawcdugKJ3PKllX0oTaLwbFescTHH49+s/orCBKXjzAX9ACkb93Cm/EKB3VxH?= =?utf-8?q?nu5VGc4WbM1Vkhn1ang1fQqnDYwfpegWwpWEwiFUqHBZugfQgziss8fK1N77AlFAL?= =?utf-8?q?Y64K0ewLMx0rWXWjT+VfKP5WzQCZAlGr6W16z/vS8oWeJN3KCOxJ41ciS9UbHQ+bd?= =?utf-8?q?XBx8f6tqv0Z1qz/rSFoaS5tSrXR1ikVhsCrY3HW0cDbD1wFfUptjKRE+s35IFCnTw?= =?utf-8?q?h2Va46DOiTXZUMXybZQH3T0OwjnGgI1H5jiUavufwM9Iciu+uWAwSHH+FcjQeueJ3?= =?utf-8?q?MId4mTE6fiS6eG9j4jDIo9VImvS790l2XwoszVE4/qjJ++PudqSI7CWsKa2HjNF+y?= =?utf-8?q?RRy4Vbd2apAFW1LmWeabJGzLIWLczQiVs4adD/055Cu8bXtz6HpWHc2xfPhbIcE70?= =?utf-8?q?K6HkqpQJlJmVuOBGFzQSjcqwZf5nSp4uFKqbC/kHmawSnemxz/fQ0NFAGf+tGb8jG?= =?utf-8?q?cId70qZpeYZUafBerxfGZ0IO6QvaUmtHSQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: dn8WtYHC2WiqRKzT3MDtwP1UOh8aVAQjGoEYQ64ukoG66iamCohRBuhIQhxy/SlGnslH7tWKMElRcq55DTIhB1QJemeLEN2mX2O9v0CqWibLexFw7BLCc54ABHO/OPkMzx3VL2kYgKgXum17R80mABZgTRW2FV8ON8fsO6j7gVZwdziZF4452MfH9IWVNVocbJw3C4MtbXAiLfPqvjNDZBAE6y5TXHsVE3d+oAKO/dEB6BJfDEH4VaWYVXoCBPhLxO+Thi8BiYk2ld0a/FAq24bAc3DnVuGPjIY62w2K7w29PDMlGq7PvlzuaQeqqQJOpHpYO90vz08br7znE8EdFV6hgqvB4wKOI9F+yHoO3Q09MiwdE6FlvzBbKhPcT+ElfvVg05c/qYg+PrqmidahE1aZf+3pDKOSYQlQ0ssktEKOeVT3iIg1VUfl75qQVMghCgH+Or4EGRslXtoIck32PxDmkJkD7YWlc29FMePPdSeG2Yuwpd/IZsCLGmozw1YAH77EUlDwk+vzq4JUIrPU8kq/da2W4XCgKgtVfoDlOBiGu5jnFmfDuHLBWsILTi1NX74nqNT66kYBzWBDExy0dIG/ZubbqSGUUQk/09nGxZuNTTGGL0zgLsxvvI7i9XuaDxC27uxJxpQ+wEGQLLwZkn6/e5jx026CR/65BMcya05IfaeFGkC7P+C1PiTYEiYUIuM1Ebo11E5Y7A2xBtorRnmxyaUL6Lw4qTwMJioJk/hKoPqbi99cGalebtOsi2bFKjlfIt9aojeQ0NegpnD3UpMq44FYrRwdzhNXCx8GGTa4miAtMOh6+mwJbhlzDvEtlXjOVfh1hXnDl2ImT8ik2PEaAjhQPBLcS9mE0hoQbzA810z6uwyWaed683c5xxkDi0owXNPBgoNr50RHwsnhkA== X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22aa39ee-72e6-4dcc-f001-08dbc359f15f X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:12:07.4292 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SjOKrg4T1TZvzCEIAyGpSoesmMsZUwI8XC5TVnMsMVCgOXjrPead9C0y+nJ9PEPfr0qv8q+1CpxxKobs++0+Ww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB7261 From: Jan Beulich Before adding a new vCPU operation to register the runstate area by guest-physical address, add code to actually keep such areas up-to-date. Note that updating of the area will be done exclusively following the model enabled by VMASST_TYPE_runstate_update_flag for virtual-address based registered areas. Note further that pages aren't marked dirty when written to (matching the handling of space mapped by map_vcpu_info()), on the basis that the registrations are lost anyway across migration (or would need re- populating at the target for transparent migration). Plus the contents of the areas in question have to be deemed volatile in the first place (so saving a "most recent" value is pretty meaningless even for e.g. snapshotting). Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Reviewed-by: Julien Grall --- xen/common/domain.c | 43 ++++++++++++++++++++++++++++++++++++++--- xen/include/xen/sched.h | 2 ++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 76a4c2072e10..d4958ec5e149 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1644,15 +1644,52 @@ bool update_runstate_area(struct vcpu *v) bool rc; struct guest_memory_policy policy = { }; void __user *guest_handle = NULL; - struct vcpu_runstate_info runstate; + struct vcpu_runstate_info runstate = v->runstate; + struct vcpu_runstate_info *map = v->runstate_guest_area.map; + + if ( map ) + { + uint64_t *pset; +#ifdef CONFIG_COMPAT + struct compat_vcpu_runstate_info *cmap = NULL; + + if ( v->runstate_guest_area_compat ) + cmap = (void *)map; +#endif + + /* + * NB: No VM_ASSIST(v->domain, runstate_update_flag) check here. + * Always using that updating model. + */ +#ifdef CONFIG_COMPAT + if ( cmap ) + pset = &cmap->state_entry_time; + else +#endif + pset = &map->state_entry_time; + runstate.state_entry_time |= XEN_RUNSTATE_UPDATE; + write_atomic(pset, runstate.state_entry_time); + smp_wmb(); + +#ifdef CONFIG_COMPAT + if ( cmap ) + XLAT_vcpu_runstate_info(cmap, &runstate); + else +#endif + *map = runstate; + + smp_wmb(); + runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE; + write_atomic(pset, runstate.state_entry_time); + + return true; + } if ( guest_handle_is_null(runstate_guest(v)) ) return true; update_guest_memory_policy(v, &policy); - memcpy(&runstate, &v->runstate, sizeof(runstate)); - if ( VM_ASSIST(v->domain, runstate_update_flag) ) { #ifdef CONFIG_COMPAT diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index f30f3b0ebeab..6e1028785d8c 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -232,6 +232,8 @@ struct vcpu #ifdef CONFIG_COMPAT /* A hypercall is using the compat ABI? */ bool hcall_compat; + /* Physical runstate area registered via compat ABI? */ + bool runstate_guest_area_compat; #endif #ifdef CONFIG_IOREQ_SERVER From patchwork Mon Oct 2 15:11:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3FFEBE784BB for ; Mon, 2 Oct 2023 15:12:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611619.951172 (Exim 4.92) (envelope-from ) id 1qnKas-0002is-9o; Mon, 02 Oct 2023 15:12:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611619.951172; Mon, 02 Oct 2023 15:12:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKas-0002ij-6o; Mon, 02 Oct 2023 15:12:22 +0000 Received: by outflank-mailman (input) for mailman id 611619; Mon, 02 Oct 2023 15:12:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKar-0001wY-35 for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:21 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 12fcb395-6136-11ee-9b0d-b553b5be7939; Mon, 02 Oct 2023 17:12:18 +0200 (CEST) Received: from mail-dm6nam11lp2171.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.171]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:12:15 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by BY1PR03MB7261.namprd03.prod.outlook.com (2603:10b6:a03:526::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Mon, 2 Oct 2023 15:12:13 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:12:13 +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: 12fcb395-6136-11ee-9b0d-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259538; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=a/AJPPtiiInCeVF/0s1F5KgDnLN6kpPIjcJ+zFRlvr0=; b=IeiAIn72J3B3QDiJgikfdEXlggsJOPcAJOnEUtpvrXBrUYz386XMclPu dweNiqKmTB5VKDRhq8OjzcWoSQdlWbw7e42tIqTi8Six7PxKrpyOV7wke wgfJ4WDVggRk+71jsuTOeBjxFflJdzsF+30oJLMJwQQPtOuOW0M3BL7/f g=; X-CSE-ConnectionGUID: nSL1cQw+TDCQ/26z7B39yg== X-CSE-MsgGUID: jDPny1WPQSK2qt4J9RWQhw== X-IronPort-RemoteIP: 104.47.57.171 X-IronPort-MID: 124398882 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:V6/kJqBZY46umBVW/xviw5YqxClBgxIJ4kV8jS/XYbTApD1xgjUCy mQeDT2HOPmDNGX3ed8ga4/lph5Q7J+ExoU2QQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48D8kk/nOH+KgYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsMpvlDs15K6p4WtA5ARnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw/N1TWGp36 r8kBBs0KUrdlb2cm+OqRbw57igjBJGD0II3nFhFlGicIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI+uxuvDG7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqC7317+fzXmTtIQ6FpGA8O8zv2Wq/U9JEQFKdwqBnsC5lRvrMz5YA wlOksY0loAi+UruQtTjUhmQpH+fogVaS9dWC/c96gyG1uzT+QnxLmgJSCRQLsMvssAeTCYvk FSOmrvBBzZirbmUQnK17aqPoHW5Pi19BXAGTT8JS00C+daLnW0ophfGT9ImHKvriNTwQGj02 2rT83F4gKgPh8kW0an95UrAnz+nupnOSEgy+xnTWWWmqAh+YeZJerCV1LQS1t4YRK7xc7VLl CNsdxS2hAzWMaywqQ== IronPort-HdrOrdr: A9a23:ffj3m6rL0fAhDsLfZzA91joaV5oveYIsimQD101hICG9E/b1qy nKpp8mPHDP5wr5NEtPpTnjAsm9qALnlKKdiLN5Vd3OYOCMghrKEGgN1/qH/xTQXwH46+5Bxe NBXsFFebrN5IFB/KTHCd+DYrMd/OU= X-Talos-CUID: 9a23:PW+oAmqb31P79+koz4X3o9TmUcYeViTW9WiTH2OTMCEzFq/KYwTB6awxxg== X-Talos-MUID: 9a23:OU2mvwU+s0Rw1APq/D3AvDdzbfhQ2p+NUlkRzbdXgfa9NTMlbg== X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="124398882" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NY6LluRR+YdsfBBV7azOTAqzl1Xpvr76iY0t8iRumJqdlJpzEVBUE+n03DuexmEUEyPgreX2GNi12IL3kjmSiuU7f4EJxPC2Wj1MDL4bYarje1WoNBtSzOXmaqcFsXfW8CST/KeF538OyoBs3NXV7ptHiU4ehSEheyl/DQwtQdyzuQUTVj+Vr5IK9frKvFtA+0IWfof6VXhQGqcQ7a/WOuugqesPmnF6jfI0fNgdABF9qX3vBMolyZLs9cGwyIYd+iNhEB8UIXYVnauIsZ/80LWw1HDCAH6ke/1lM0Qo+MisrJvFeqBn9X1bpQnMISyrKS+OxCuZbv4yOTqCHPCouQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wNopSXtZurBZ4E6tSOFy4W/8WMqlD6/cPCnqWUU/QCI=; b=QPJMyL7Wf5ideIxR2c/73Jhlxu9PK0JNHVks6e14fNJ6WXU5IyRz38VZHzbHiEiBTj9W7hlCCWhix0dBDP+44t1un4dvfhnnZDo0oSaQlRlv//pen+EuWM2tYiEwornLtEjvnSY4bnvne34TWpVCHI0jYWa3nw0Q0TMMbtZFdd3C2/S82uYBmCAhNifMKNAwvQYzlB9shf46xzGk+UdASKNHa9UyRfX0LaVa5alqizKNzcwC1ZV4UK7diTJmcXZMewQIvSCNfM6CgyLYVWLB5wmzx3QrZihVdCaui0rWaWBAZR/Qg/hwTqgo/YHaBz8YQqZGWpa5vKm84m89lRPWhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wNopSXtZurBZ4E6tSOFy4W/8WMqlD6/cPCnqWUU/QCI=; b=hEYQqPwGaW4ru+0Gxjhlw3vD1XoNRzEMu2mmbvSAGvZvWVgZCJ1v509n9QEmeSHpqv6AmHYYH2RWznJCZ8bUVDKOYVzATNY+7WyGXF8qLD+qRtvt3QOM68jCji8Lky1J6e4O5PmCQ6qfyfGQZOrGgo/pVIh8RBJwNfuHpHLRK4Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH v5 05/10] x86: update GADDR based secondary time area Date: Mon, 2 Oct 2023 17:11:22 +0200 Message-ID: <20231002151127.71020-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0483.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::20) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|BY1PR03MB7261:EE_ X-MS-Office365-Filtering-Correlation-Id: a1f80fff-3d39-46cd-2972-08dbc359f4cd X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KsjqnjP8HSqcz1r/jmxL8+7mA078ZNXbNRwz5KNLtoHuHUZatZc+WXUfDMfACD5QwgM7plLnZf3SoO5JlwWg5pbaQHyJFX0s7MsUSvCelvBGp7rIrM2eB2iKrTq29VF+HP8krU1dSQw3l+q3SIZhiS6CBDklWHQ7EhyTaQoIbl9HEdFvMgRsTIt3HmXfdVH/OTdQx7/XYK0ydmGA2/EaULKnJ+0V5cKAGqUc8CFmK7iFcCD4bkYQAjNsRCPZg9B7PMGlK6okpJ6GU5JgE0Kcgaz1fJqP975URVeP9KBdt4p9F50CY77LIByP4jJNzjwlYWYNxxxVANrbJ5kEQocC8bgSPVujcSt5oxcg4WrzE3erQ9XzDC6L2lVLqp1KjQxxAppTS1cknDtPww8HGoQdTGcxFrcHPUzPurfcsbuOV8SPl5KY1XSNyXv3X4afD6sFr8tzfFsfgTopp+iOfMdaErrrAYTDtqoioNzYtqKUTuIzCMZfKYV40+hnYZsWFM7DAnKmkkRTYuFcjUVLlEP5NZBLjoB1gvqRyMJhpCylJ+CTz2W54S/LBBQVMXeSaIx6 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(346002)(376002)(136003)(396003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(4326008)(8676002)(5660300002)(8936002)(6512007)(478600001)(6666004)(6486002)(2906002)(15650500001)(6506007)(26005)(1076003)(83380400001)(2616005)(66476007)(66556008)(54906003)(316002)(36756003)(41300700001)(86362001)(82960400001)(38100700002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ol4uef2QIHe1TCLV+vydAd50OC1i?= =?utf-8?q?pGobUFLZLA6HuzY4qjctMKhpk/U62Rma1NgmMtcYibXPbu4XQSENDx7TOEbrlcvEW?= =?utf-8?q?LUlf4Pena3/y7oEL7M3snIUA885VRCsGAXi/ymOBGwJRrPOqvkl7QlKA9bInymwzP?= =?utf-8?q?zLQPmJEcQ00+X354Nfwxdn/iKNzsZNCtfFEqxh7hXfRrUu4WVVyWB9olYgirzhGLk?= =?utf-8?q?IOqbCN3pQyaMUv1qugsHv4jtCIfqCk8bCOYPkzew39egKMIcujsndkPlejuYnsDI0?= =?utf-8?q?ZiN2fqhe2NOn8/oXmaLyjgOo62+YR0BQissKtZDgsOShXH6M2YrRFJSG2EAd9p/XH?= =?utf-8?q?YEwDVCulXfnA4p+Hj67F0rsW7kjf5Z1psRo9qFPM2qDIlkCO7B/CIzsRwo98jA6se?= =?utf-8?q?YvTXe0+waOSJI9rzipgd4wq3VKy+6cNeBH9zgR42ORGbpihpjiHFdaNfRBwyO5tT5?= =?utf-8?q?fFfQurxqOmd5cuY1mXG1JW/lODz+s/0ELouye/Ro3S9pUz+4QIYZv1mrL3RbNswcp?= =?utf-8?q?kkBJJxb2JNr6PfelgvpBwbqC/a47UwH6u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X-MS-Exchange-CrossTenant-Network-Message-Id: a1f80fff-3d39-46cd-2972-08dbc359f4cd X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:12:13.2058 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NNdYtbDuNK+9oED38dcI/JZm403Hjx8qLAkxwoywdphKik/ezoDxqLOdxYOui1oAfbIDRPdH+8+Yr1VFSpv+fg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB7261 From: Jan Beulich Before adding a new vCPU operation to register the secondary time area by guest-physical address, add code to actually keep such areas up-to- date. Note that pages aren't marked dirty when written to (matching the handling of space mapped by map_vcpu_info()), on the basis that the registrations are lost anyway across migration (or would need re- populating at the target for transparent migration). Plus the contents of the areas in question have to be deemed volatile in the first place (so saving a "most recent" value is pretty meaningless even for e.g. snapshotting). Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné --- xen/arch/x86/time.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index af40a9993c81..332d2d79aeae 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1566,12 +1566,34 @@ static void __update_vcpu_system_time(struct vcpu *v, int force) v->arch.pv.pending_system_time = _u; } +static void write_time_guest_area(struct vcpu_time_info *map, + const struct vcpu_time_info *src) +{ + /* 1. Update userspace version. */ + write_atomic(&map->version, src->version); + smp_wmb(); + + /* 2. Update all other userspace fields. */ + *map = *src; + + /* 3. Update userspace version again. */ + smp_wmb(); + write_atomic(&map->version, version_update_end(src->version)); +} + bool update_secondary_system_time(struct vcpu *v, struct vcpu_time_info *u) { XEN_GUEST_HANDLE(vcpu_time_info_t) user_u = v->arch.time_info_guest; + struct vcpu_time_info *map = v->arch.time_guest_area.map; struct guest_memory_policy policy = { .nested_guest_mode = false }; + if ( map ) + { + write_time_guest_area(map, u); + return true; + } + if ( guest_handle_is_null(user_u) ) return true; From patchwork Mon Oct 2 15:11:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97146E784BC for ; Mon, 2 Oct 2023 15:24:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611655.951202 (Exim 4.92) (envelope-from ) id 1qnKm9-0000Gg-53; Mon, 02 Oct 2023 15:24:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611655.951202; Mon, 02 Oct 2023 15:24:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKm9-0000GX-25; Mon, 02 Oct 2023 15:24:01 +0000 Received: by outflank-mailman (input) for mailman id 611655; Mon, 02 Oct 2023 15:23:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKb0-0000iK-TO for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:31 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 198510d0-6136-11ee-98d2-6d05b1d4d9a1; Mon, 02 Oct 2023 17:12:29 +0200 (CEST) Received: from mail-bn1nam02lp2041.outbound.protection.outlook.com (HELO NAM02-BN1-obe.outbound.protection.outlook.com) ([104.47.51.41]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:12:25 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by PH0PR03MB6680.namprd03.prod.outlook.com (2603:10b6:510:b8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Mon, 2 Oct 2023 15:12:20 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:12:19 +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: 198510d0-6136-11ee-98d2-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259549; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Wmu57Iweb823GQ+wLjFQQNOvbip8ENNcd7NtaI7MLwQ=; b=aI8rct8KLy1qSPrjQ3Ao32aMqGT6Dyu4IhzXADtJU6iwFrmCrTQp7QsZ F6DdYsW2McBgig5NOdEfrYnwrUKG99Bss4rdt7hHVgFq1Bc5fbEPLRUF2 lHVz4IC3s+JjxicZjoPR+adaMg0C/U+WbCoJmOj8mReJwkiwGgR6JetEI k=; X-CSE-ConnectionGUID: 17r7I/A3QciTLPErLc/vrw== X-CSE-MsgGUID: Y0x82eQ+TISu8fIK4QEFhg== X-IronPort-RemoteIP: 104.47.51.41 X-IronPort-MID: 124817032 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:Q96Os6pC4yEPYum1KkbfKLXgU1heBmLuZBIvgKrLsJaIsI4StFCzt garIBmFOK3ZMGTwKth2PYXipkkE6JbWm9RmSQU+/ClkRHkSopuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbOCYmYpA1Y8FE/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GhwUmAWP6gR5waGzyNNVfrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAGlSdE+iwMvt+bm6ds1Uq94HJ471JpxK7xmMzRmBZRonabbqZv2QoPV+hXI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeGrbIO9lt+iHK25mm6Co W3L5SLhCwwyP92D0zuVtHmrg4cjmAuiAt5CTeLgraQCbFu79zQDWEcbbBiHgMKk2kCfeI5mB mIU9X97xUQ13AnxJjXnZDWorXjBshMCVt54F+wh9BrL2qfS+xyeBGUPUnhGctNOnM87QyY7k ECAmdzBDCZq9raSTBq19L2ZsDezMig9NnIZaGkPSg5ty8XqpYgopg7MSttlH7+4ipv+HjSY6 y+OhDgzgfMUl8Fj/6em+VHKhRq8q56PSRQ6ji3MRX6s5A59YI+jZqSr5ELd4PIGK5yWJmRtp 1ABksmaqeoIVJeEkXTXRP1XRO3wofGYLDfbnFhjWYE78Cig8GKieoYW5yxiIEBuMYAPfjqBj FLvhD69LaR7ZBOCBZKbqaroYyj25cAMzejYa80= IronPort-HdrOrdr: A9a23:vjMu6Ks04Z9IIHlevf27gO117skDgNV00zEX/kB9WHVpm6yj+v xGUs566faUskd2ZJhEo7q90ca7Lk80maQa3WBVB8bBYOCEghrOEGgB1/qA/9SIIUSXmtK1l5 0QFpSWYOeaMbEQt7ef3ODXKbcdKNnsytHWuQ/dpU0dMz2DvctbnnZE4gXwKDwHeOFfb6BJba Z1fqB81kedkXJ8VLXCOlA1G9Ltivfsj5zcbRsPF3ccmXWzZWPB0s+AL/CAtC1uKQ9y/Q== X-Talos-CUID: 9a23:DkldGWCjkBtp7zT6E3A47hE1Xel+S3bc8FPoDlWcAiF3UqLAHA== X-Talos-MUID: 9a23:rpP3kwlfC++2O4zE68F7dnpTbNc4uamXS3wsqohWteinaRVdFTeS2WE= X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="124817032" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ijVBSAH1E9YQm/+RCyuPbs9r4A3PfVJK6X/TQLGxd7jMFFhWSu0XvDX02bCHpKM9JHEyagfdUedlb69SaMcBz3PRwy0rLR01/UBQZ8pX0+qcpHuES7dvoDXguBWMWVA2EAzBzV2v6/qgFVJq+AM6jqJ5XfE6Z3c9RuMlyWT+p4aGaCxqE1g0bxcNcUVX3YO44h1tPYjEf3Rw5CHtFiXId1JMbr0IU5C80xCFGYUP72lhYQVSyc0O2uHFR2J18perd5fPPfG8vK/SfryzdcfFuFETLo7+dT1LJgrCLyl0tXpzWoVqBZrT6QuloQPK8CgDpLEizSTVR4aX8zBNAiC+eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nvG7viCgQSkvoHQeBIteDFdRPqHhGGdm2eXXhEsoH1M=; b=F1xlt7C10eGaajsY+JSCnVRwUBX4DCKUW4xsPzSz8IeJI365bHfn3uwSfBluPkUn8rwuoBRAikJld8Lqu3Bf5h0+Ce10McXOxQPW5AzU1p10qiiKOTsyWIKm9n99tEZL+ZVtVs4B6XGZrkloTI3l4AvCM/eJxRixDpfz/SbI9ZjlH9Bk+gG3aSKxtvckSILYBXMY0fVdapOIa3E4heLKCB+/awb82prxq+9pczC4uNeulRVvVksCE4qVbcMs1xDVkoTnxYmlZhBOrr8QeZ8qUusUR4H4PRiVdbdzch8QJS2q9dm5Pkxf19UKWo/6e1ViOsk3Vyo5z0FZO2OCdXI0bQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nvG7viCgQSkvoHQeBIteDFdRPqHhGGdm2eXXhEsoH1M=; b=EjX48Uk6vz3+maFxMsbIzx6buFCGHFxQwehUB9iNLc0oKzYuwBHJW/a/h/FzaUh/CJ77FyXAJxEKwxvx9NYS7BJyej0in377R7d2SnhqDMbE4xMffesJiA/FsyJduEMD0ATqWm/giOXelQGza6cTSp/sqa151yqLD5KhSUFO09I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Tamas K Lengyel , Andrew Cooper , George Dunlap , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Julien Grall , Stefano Stabellini Subject: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas Date: Mon, 2 Oct 2023 17:11:23 +0200 Message-ID: <20231002151127.71020-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0168.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18a::11) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|PH0PR03MB6680:EE_ X-MS-Office365-Filtering-Correlation-Id: 048fe6c9-26a6-425c-3660-08dbc359f871 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o0aZu6URk6qrBrXCnjvk0o2cgRxkoHQ7WLTEXSuXT4G/lxOvxW3so3DXGwsQ8OQMZ1eDUuDsiXAwHK0scbuleeSasBJytL/bX+TBfGjPwjvhhbNWOuKLNbde9FsHpYaEnnJQ7REIzLn0reeNBGmVPNEdih/yQidKVZxkiFYdB033oLQ9fdaYh/lDnCg4qt0/smNtaBRDkoXpCI7GKaA1Yijj3eu4y+8iFmCQsuk0WzA7BqAeLM9d/DdUiVVouOzk0olH+BaEXZeisat4rA+ol4+kexAsIPnK2W/hVcPUcYHWlknTkVtI9uCHAhA2p+Cv5dNFOYXqqPkRwM8Wdf5NARjBid9kKd0weKnK7kmgqtIF1jLYXpqOZwxtzara78YeRoonLxFtnp5tUbZlLF2/W/mFxKMWa8cMwMNHSFyXSYCvQ6yiuENDLXT8TyQiZE12Hr1DBoPLU1eAXCEl1w5yP1RLgT9VRs74VmviAct6UmIjKLz6AvId7UE9F5PopDtxoqPgGudDAfcrkuBSDKl0wso4KiHYg1OjI/55adM/bFlfo3MdC6PJ5Iop89iwEOUn X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(366004)(396003)(346002)(136003)(39860400002)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(36756003)(2906002)(7416002)(26005)(478600001)(4326008)(8676002)(8936002)(6666004)(6486002)(6512007)(6506007)(2616005)(1076003)(41300700001)(316002)(54906003)(66556008)(66476007)(66946007)(5660300002)(38100700002)(86362001)(82960400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ZhO4HXBFbQLm56BG6R++4bOcdp0M?= =?utf-8?q?oAzEWac2N5/3gU7fSIG5JopOoL+TmBLC60ATn71CCNjj4LOjtLH8Df7iIUj66qAkb?= =?utf-8?q?KTlTxbfp0qeouXhwxE5yTqXm7FgpBwNMI+UdARB+KhaDlu7ccm+Aqm97PEc9nO504?= =?utf-8?q?A89I8JnaMWGrL0TI09x1+VVfQt9aysSkNE21H3Vico0+MFbRwdXAasx9vPIm9vCW2?= =?utf-8?q?4j+iIgHWtDN53HQxDtR357I7JovLirNEn0LypUzOZqX/DGDIHtIWDI11wTwWohjo8?= =?utf-8?q?rvIQhGwiTyDakdPgqX6pqnGO01rnClFDdde3wtgD+s6s+Oa+g0dlYklI2yQQWvL3m?= =?utf-8?q?m5g9EA1FkScIlDWqApL+Tu7cJ/mCBleKUQRGiGjT8YfztZCi+P+xeLvW+CqcIqXuo?= =?utf-8?q?qpfdTEcobE8edDbHGxMwUichNa74bKtP3hxUPYiM+VjlFYmLB209eRU0+ibV1oFAP?= =?utf-8?q?zopTxN2CrA10nRMLQOfhW3tYW6RIYYqlHN5W7cVqTcqbiFRq7rXljZ3v6enAAdq14?= =?utf-8?q?UqK2CXC3TXejEQwp65v3YkC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dRhLPSyuNGsbv0MTYMICwNpZjhJ75oQZbF7GMnzNdcUV9FT789cHa+sXBic4uct1XEAy5rBM= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 048fe6c9-26a6-425c-3660-08dbc359f871 X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:12:19.2895 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ul2ZOnIbcaYNCp/oRCJoS/UtestZo3QuqEcgayIi/Gc2xT7xAFIes/XeZrCkKZMm2bWJYh6jRpg41FIx7+qnFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR03MB6680 From: Jan Beulich In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in). Signed-off-by: Jan Beulich Signed-off-by: Roger Pau Monné --- Changes since v4: - Rely on map_guest_area() to populate the child p2m if necessary. --- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 5f8f1fb4d871..99cf001fd70f 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu) hvm_set_nonreg_state(cd_vcpu, &nrs); } +static int copy_guest_area(struct guest_area *cd_area, + const struct guest_area *d_area, + struct vcpu *cd_vcpu, + const struct domain *d) +{ + unsigned int offset; + + /* Check if no area to map, or already mapped. */ + if ( !d_area->pg || cd_area->pg ) + return 0; + + offset = PAGE_OFFSET(d_area->map); + return map_guest_area(cd_vcpu, gfn_to_gaddr( + mfn_to_gfn(d, page_to_mfn(d_area->pg))) + + offset, + PAGE_SIZE - offset, cd_area, NULL); +} + static int copy_vpmu(struct vcpu *d_vcpu, struct vcpu *cd_vcpu) { struct vpmu_struct *d_vpmu = vcpu_vpmu(d_vcpu); @@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d) return ret; } + /* Same for the (physically registered) runstate and time info areas. */ + ret = copy_guest_area(&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); + if ( ret ) + return ret; + ret = copy_guest_area(&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); + if ( ret ) + return ret; + ret = copy_vpmu(d_vcpu, cd_vcpu); if ( ret ) return ret; @@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state, state: if ( reset_state ) + { rc = copy_settings(d, pd); + /* TBD: What to do here with -ERESTART? */ + } domain_unpause(d); diff --git a/xen/common/domain.c b/xen/common/domain.c index d4958ec5e149..47fc90271901 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1601,6 +1601,13 @@ void unmap_vcpu_info(struct vcpu *v) put_page_and_type(mfn_to_page(mfn)); } +int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size, + struct guest_area *area, + void (*populate)(void *dst, struct vcpu *v)) +{ + return -EOPNOTSUPP; +} + /* * This is only intended to be used for domain cleanup (or more generally only * with at least the respective vCPU, if it's not the current one, reliably From patchwork Mon Oct 2 15:11:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7683EE784BC for ; Mon, 2 Oct 2023 15:24:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611658.951212 (Exim 4.92) (envelope-from ) id 1qnKmW-0000oB-CY; Mon, 02 Oct 2023 15:24:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611658.951212; Mon, 02 Oct 2023 15:24:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKmW-0000o4-9T; Mon, 02 Oct 2023 15:24:24 +0000 Received: by outflank-mailman (input) for mailman id 611658; Mon, 02 Oct 2023 15:24:22 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKb2-0000iK-TT for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:33 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1aef2bec-6136-11ee-98d2-6d05b1d4d9a1; Mon, 02 Oct 2023 17:12:30 +0200 (CEST) Received: from mail-bn8nam04lp2045.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.45]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:12:28 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.28; Mon, 2 Oct 2023 15:12:25 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:12:25 +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: 1aef2bec-6136-11ee-98d2-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259550; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=psChbXevVQDev+FecL8Znn3KSLaq4hCGvgjWrrp1GF0=; b=PLDqXYYt71ySyDpLloJFQvwiebvQwxds0R3F+MeA7No7xSuTrKYs1oC9 bTPFxpojngfxH6Tg9dzPy5QwOnNnlixv/NO0Krzz93qqjhaNrhaeSImNP MnVyj8LbCjpzF+4JNz4fkb3hz4zai125omDmDR4aR+nVB+IVo5EJf8WW2 s=; X-CSE-ConnectionGUID: A9L7y0N9SiWSdMHovdX94g== X-CSE-MsgGUID: EDmfyoThTZGrEjmFdJkNDQ== X-IronPort-RemoteIP: 104.47.74.45 X-IronPort-MID: 124817058 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:MqvB86DRi9i8KBVW//Liw5YqxClBgxIJ4kV8jS/XYbTApGkggTcAy 2UeUW3VOveMM2D9eN4iYI21p0pQ6JXSz4cwQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9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/vo8rucyqOQ5zHRuk2WE= X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="124817058" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d7+yE8xU+03OhcQfKfQkPtIq2J4q8+vFFW/nSnABIaLhqHSwGVw9UMXrOjsgpbHpiQEl+EGGYMSL1RSiCAmeE7z/03rsxasjrngwm9x5Oq+hQclw9+sGfN3CBe+CFYqqEvp33FUSAWwR4OCETyoO0q24goFWl6xVA6t7kCk0vQmO2upWDD3RoaDBtUUTRTp53EnkNrRzZ4ffuqRMw4N6fwlXfIOxOcgix4zQuBoKestxMRtkM/L9wfHfE1NeHlzVuQgjZrrF27y/GSec03iwsrkKKj1/bGb699P7AaZbpzn41cectRBaOQkB2QHFikXp3P/tHcYHOyGddA5d7mjtpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PHzEv0bBVjJyC3Xd0ymJb5ygmas8Z04naThhX+BBIfg=; b=QPwANCEejrhVdj46jA5TUpsQBt+XEw254v0oUqjLU4+RLikqwYlXavleNMCEW4HL9VYVSxpMmQQL6CqBrZ6+83n1GU+1R2RMSc3sSzs0MYY3zeXrrONwuh7PzesrGMjP5uQvbyVei8+ROhRJEG7QxWxjDpACh7OOQkUzaUvJT7Akb9OGlWWdo+8w9QaHFqdYKOd8fDhoGvbuyiDjQgbDCWjILbT+J1wT3bbNnmY+3xcU3XLT/VD/cbXP8QiPhlv4SwbbE4sbTI5a9CipkqxKF0O3rgx27PXzJdWqVVbZT0jMTE9nrW7WIrfOzHY5YguMOTdZxv9v3xCzaeXqg8XHUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PHzEv0bBVjJyC3Xd0ymJb5ygmas8Z04naThhX+BBIfg=; b=eaYNIs/4MoFlul1RibCXcV50eVOEoZ5YPo0pLrhQWcWW16gxzcy+ORF6Wh7RacWyfS4YkJYwOJ606L0S0wwwkiv0iQkj2hRyREiY1LCQ2dod1l7IiZcCl/f2VrmYCwDPSPLwf65djj9ZtIc+qiOWm0rFflowogYKbT02ZZpXpHs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 07/10] domain: map/unmap GADDR based shared guest areas Date: Mon, 2 Oct 2023 17:11:24 +0200 Message-ID: <20231002151127.71020-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0111.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::8) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|BN9PR03MB6188:EE_ X-MS-Office365-Filtering-Correlation-Id: 26aadd2b-5455-42af-3424-08dbc359fbe3 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gEzwI7qaiwqowvA7WR43F09zOYVyQSpTlFjycOKamLEs86Hx7ChEYIchIDyKizgBhtgVRihvydR+O+4VCfGbKeRqLIcaY+ubtDgX+sbQ+2HS8+M/31EUZUvo8gBFigVRKwzE0WPpPJB912iTs1rzOFMwe5TUNRNcQwnw5fNPxGu4rU/T5cWx+nWch48ydnsm1E8GyQpsB1Q18RZfI2YqqP/tW7AvpuqPlZpI30/YCWCbmthj3TvnfsvsQcr9SjYHaWvRzQZfGbrMgVD2i4Y9TRgD7qTawy9ik0mMSZZD2+fze2XVMqWCsiLmzpmQ5PGt+V8kwG+YZfckUkVKpZXDQxUlFjn3W70EmFMegeFYckOM00aQb9abE63uGT9wysL+8nGR4nu5e20GX8mS7lVfVOEP7+l1S2itU7VkneT6KdP17gYCNT96JCVkFID25P76jYvndYq3Rx7fmfJsUPLLLiYbvDvwS2RpVpjHJFRNoRiuGVCKWh3fl6YEJcLsE3ED7kOKP2sjLLzcVc8shqeyN6/WOUy8fcsFnOSEMDEMOAOlCvsy4yDGWBHpBj/EdvLW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(2616005)(107886003)(1076003)(26005)(83380400001)(82960400001)(38100700002)(86362001)(36756003)(316002)(54906003)(8936002)(8676002)(4326008)(5660300002)(41300700001)(66476007)(66556008)(66946007)(2906002)(6506007)(6512007)(478600001)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Wl3uIHRcQQ0CF4XzynP7qy0haUOy?= =?utf-8?q?FjKzb5C44I7V0gbX/TXmq0GUlQrEcHPr3bXRnIBSikKPP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SPIaJ5kxbBVhUsdZFVaBhNpLbh6S+v9inGmGAfRh+ik5P7uVMxd4elxuBRpeA2RNk50Pz2dE0qAytfuM/PmnJcSrvOgO8S7T1X2dngq9htq02LAEYtL2DBuoH+4Ujzy03UnNmG4lujbWAoKlpc76dXTseAh3+JoD3Li6FDUUwKekdN5lLjynQhw/aMo5OcPnug6BKkmTJWpawvmNCU7R31sUrET7LMrs/z5tgORP8onzXukYxYKSbuRVeVzoHSs5f6/zf/1vvGt9TNSF0BPaaX8pIHzv+IrFsaWtGOfbCzaiYV8LGW2tYQD3OH0+DUluDbGb51IZ9IsXfT3d2rMK2+3IYM6zjLWRfpybck3cC27fZeT60Vf8N9ZgxlQmMfRP3rpz6J6aXoVwUbJByurtKclj8QRsO0LcaHfF6R7c+IjhxvCNY61u9thHB8xr0R4fRgeQ7/NCYCMAoy+kNTG94TFTldAFHmMUWIfL5r99PBueGS9pzTeA+zTHrBkLLmQZaYjFwZbUpFhWrawywgHiwo2lhCt/xjDfn/mZ+ipix9OX3sqQWyXc7QjA65rP+iJeXHfB8jvj+TftXrDotUwZQJ88CLLhrQ7theBWmDYlX7G8ng2a9RMiagG3EebaIuw2jO7gQbZbgxkE5rjddG X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26aadd2b-5455-42af-3424-08dbc359fbe3 X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:12:25.0681 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8TV/QUCpK8ivYHdsotAi9iDzEZ537Hd1qm5BXS9xLWc3KQX80BoSlACa7H2VJBoQbP+6T5vW9eQGFPFC+nCm3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR03MB6188 From: Jan Beulich The registration by virtual/linear address has downsides: At least on x86 the access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the areas are inaccessible (and hence cannot be updated by Xen) when in guest-user mode, and for HVM guests they may be inaccessible when Meltdown mitigations are in place. (There are yet more issues.) In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, flesh out the map/unmap functions. Noteworthy differences from map_vcpu_info(): - areas can be registered more than once (and de-registered), - remote vCPU-s are paused rather than checked for being down (which in principle can change right after the check), - the domain lock is taken for a much smaller region. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Reviewed-by: Julien Grall --- xen/common/domain.c | 92 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 47fc90271901..747bf5c87a8d 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1605,7 +1605,82 @@ int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size, struct guest_area *area, void (*populate)(void *dst, struct vcpu *v)) { - return -EOPNOTSUPP; + struct domain *d = v->domain; + void *map = NULL; + struct page_info *pg = NULL; + int rc = 0; + + if ( ~gaddr ) /* Map (i.e. not just unmap)? */ + { + unsigned long gfn = PFN_DOWN(gaddr); + unsigned int align; + p2m_type_t p2mt; + + if ( gfn != PFN_DOWN(gaddr + size - 1) ) + return -ENXIO; + +#ifdef CONFIG_COMPAT + if ( has_32bit_shinfo(d) ) + align = alignof(compat_ulong_t); + else +#endif + align = alignof(xen_ulong_t); + if ( !IS_ALIGNED(gaddr, align) ) + return -ENXIO; + + rc = check_get_page_from_gfn(d, _gfn(gfn), false, &p2mt, &pg); + if ( rc ) + return rc; + + if ( !get_page_type(pg, PGT_writable_page) ) + { + put_page(pg); + return -EACCES; + } + + map = __map_domain_page_global(pg); + if ( !map ) + { + put_page_and_type(pg); + return -ENOMEM; + } + map += PAGE_OFFSET(gaddr); + } + + if ( v != current ) + { + if ( !spin_trylock(&d->hypercall_deadlock_mutex) ) + { + rc = -ERESTART; + goto unmap; + } + + vcpu_pause(v); + + spin_unlock(&d->hypercall_deadlock_mutex); + } + + domain_lock(d); + + if ( map && populate ) + populate(map, v); + + SWAP(area->pg, pg); + SWAP(area->map, map); + + domain_unlock(d); + + if ( v != current ) + vcpu_unpause(v); + + unmap: + if ( pg ) + { + unmap_domain_page_global(map); + put_page_and_type(pg); + } + + return rc; } /* @@ -1616,9 +1691,24 @@ int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size, void unmap_guest_area(struct vcpu *v, struct guest_area *area) { struct domain *d = v->domain; + void *map; + struct page_info *pg; if ( v != current ) ASSERT(atomic_read(&v->pause_count) | atomic_read(&d->pause_count)); + + domain_lock(d); + map = area->map; + area->map = NULL; + pg = area->pg; + area->pg = NULL; + domain_unlock(d); + + if ( pg ) + { + unmap_domain_page_global(map); + put_page_and_type(pg); + } } int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) From patchwork Mon Oct 2 15:11:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406340 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00310E784BC for ; Mon, 2 Oct 2023 15:12:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611628.951182 (Exim 4.92) (envelope-from ) id 1qnKbA-0003n6-Ph; Mon, 02 Oct 2023 15:12:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611628.951182; Mon, 02 Oct 2023 15:12:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKbA-0003ms-Lj; Mon, 02 Oct 2023 15:12:40 +0000 Received: by outflank-mailman (input) for mailman id 611628; Mon, 02 Oct 2023 15:12:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKb8-0001wY-D6 for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:38 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1dab5290-6136-11ee-9b0d-b553b5be7939; Mon, 02 Oct 2023 17:12:36 +0200 (CEST) Received: from mail-dm6nam10lp2102.outbound.protection.outlook.com (HELO NAM10-DM6-obe.outbound.protection.outlook.com) ([104.47.58.102]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:12:33 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.28; Mon, 2 Oct 2023 15:12:31 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:12:31 +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: 1dab5290-6136-11ee-9b0d-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259556; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ZgXXFCB7psZZri2vLWarAPangJxppmH8MByerzI/jRg=; b=KtuQgsWn9iHvqjX/lMpqXsmZM0uP+17ejOBQQPKfLnGCMg7x1SGaVnEN 6L7GD0g/CSAGABaYZsKxaMEOWxIOw0Q7/6cIQRE7LI/S0cEMMpjn/3EVQ RPL3jp2fl1pNLUR1LRefbwV6MiZWLLCB2nKG6jljNWA8pT34vSHAgXViG s=; X-CSE-ConnectionGUID: a8J0aa4FTUKj0XubbixRIA== X-CSE-MsgGUID: 5q6wzXboTH+Nsoogo/sw7g== X-IronPort-RemoteIP: 104.47.58.102 X-IronPort-MID: 123016639 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:0enMZqlINA9Y16EucsT1F4zo5gxbJ0RdPkR7XQ2eYbSJt1+Wr1Gzt xJNDGiEOKqDamvwc9x0bYm+o0NSvJbSndBjSgZr/ChgRiMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+e6UKicfHkpGWeIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE0p5K+aVA8w5ARkPqkT5AWGzhH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 fVICmgEZ0ytu9+VwuqLV+Nmh9QZDeC+aevzulk4pd3YJdAPZMmbBonvu5pf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVkVw3ieC3WDbWUoXiqcF9hEGXq 3iA523kKhobKMae2XyO9XfEaurnxHmgANtMSubpnhJsqACKmHMBOBcRaXv4h+K+jUG5HMlAd ENBr0LCqoB3riRHVOLVTxC+5XKJoBMYc95RCPEhrhGAzLLO5ASUDXRCSSROAPQmucksVHo13 1mGt9rzAHpkt7j9YXCX+6qQrDiyETMINmJEbigBJSMa5/HzrYd1iQjAJv5hDaq0g9vdCTz2h TeQo0AWnK4PhMQG06G6+1HvgD+2oJXNCAkv6W3qsnmN6wp4YMupYtKu4F2CtfJYdt/BFB+Go WQOnNWY4KYWF5aRmSeRQeILWra0+/KCNz6aillqd3U8ywmQF7eYVdg4yFlDyI1Ba67opReBj JfvhD5s IronPort-HdrOrdr: A9a23:LvPRMa3pPYxpmLkihSbTuAqjBLYkLtp133Aq2lEZdPU1SKClfq WV98jzuiWatN98Yh8dcLK7WJVoMEm8yXcd2+B4V9qftWLdyQiVxe9ZnO/f6gylNyri9vNMkY dMGpIOb+EY1GIK7/oSNjPIduod/A== X-Talos-CUID: 9a23:raNOjGGiU96LzCCsqmJupGxME8l5XEHg73WIE1KyA2d5cpy8HAo= X-Talos-MUID: 9a23:H1Z4fgn9exzaXXCp/55xdno/LZl38ZSkD3wt0rMdvM6LMmtrJGiS2WE= X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="123016639" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c1xRJ8i44ofkn5G7qgh1cGhlpZtXOeU+/sbOfV88+8ijPH5BAurnaTsknn5+8TCF99+kHUny7Xya7EIvQBhMAg8Zw14ItfE6u4mUcNbuRiP8q06O0ihlqXxrSwtJ5OAfqZ2Qd1g8RPoE7pwrNW1zcxEOYEho3LcHbOdXrZLXTc0wBNoJEXf1GpDXbsTAtaUDiaDNWwUwNptzX9XXHvV2VYcr1ckfz0e5BWm+6pVpyWU5+s18vveFVdFrDb1qqzlxV+1tDf/KGNOuRqBTLMfTcwredA9yNh5Kh1NXsBbUoja3LGZ92A35jjf84mLnCSdBXLWI5CatNoqeSnCJVMn0XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zMIb0nDm1DJBXyK5aOdXBIAXiKy1K5Km1lNy2ZHywr4=; b=e1bIKrmqQAGTtWWFhURo/wZeI0hM7ridFXM4oPkA3sATa0H2oaQRrC/DaoLskQe/mwxLXgH9ozW+4hBHPKvBrpZyKfWFO0mPiB+B21ShL3qGFm8Pleb/HYbJgr8vSsgU8z7ctxlP+cC4UnAPnuPLy7xxmH6LNYvJbu7onZUw7BSl2VqVXa8sIreNT59ieDhPPGKmCR6iiI4dE8hiSTNfp18UUnNY/bTcqQWByZnNYV9ni+17ozhTFWe2+3eU6tAETuGDetZOL1SHb38hqTPlnChSGe6UIM0B2K5U4dpqzdcRJ55EQHTk3ir3ArMwDyMzW+ddh18fXm+n3qC5Durs8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zMIb0nDm1DJBXyK5aOdXBIAXiKy1K5Km1lNy2ZHywr4=; b=DIgXexvpaKrGlzBg98nXULTLoUA8eeeDfzY81Csv6ragxrM6v9mb60+AxSy9gEcVQC1PnX/k6DZRkuH8IeQjFOwfbq5g9BpLix39hS7zArHsWv1N3yOjjBGTAddhPLJUXBmwknCnEjGjjMQsCWVAZ1GJ9ap8mblD/kPXDqgTa48= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v5 08/10] domain: introduce GADDR based runstate area registration alternative Date: Mon, 2 Oct 2023 17:11:25 +0200 Message-ID: <20231002151127.71020-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P265CA0278.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:37a::19) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|BN9PR03MB6188:EE_ X-MS-Office365-Filtering-Correlation-Id: cabc543f-6554-49b9-086b-08dbc359ff6d X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Rt2KNvj7FD1E5Sz3sCGoTJZfpOO1QW8lnOqYHGQV3RYBCbiVoVlpwd5QS/ZG8TH3oxNw26j298KSVzYTZYbm2w42EweQ4AOOKKHJ6rbNBEF/PYDtCqJqRWeGDV2Hjw7b6H7KoWcSp7kNt7Xy84ayVPHEkqUxmgMUX7u4qdZ94j8h7aQaw0FH06qvnVXHs/2CBU4BMKS2F3U3OMcSV4P2Unae5VwvfgEZiV6BPcxb2BUUd4PNPsKSprhZRtbz9JAK2UWhfb5WVKezVZ2MVJkYmbcHunjg9oW1edIdfG4MGU9I6Me+NXd9VPsgvLkCnSMVRC8S9G46X5vlsOmWuO1720zx/412GaYfLvgoqECxGpPMZTGeZ97+EFPpSuLZ0XtBb2Qk785yqHquwMrThgNffI/Y6DTWBvrA6GU8jcMMRl77G0EOF73xrmDEzrgxTiY8Mx3C0WslIPTq9pPY3WozS2ZiOhGtJXBV2mqvsaswGet/n1f2m+3XM51eP9KC+FxxJNcLAywj8u89Zdj5AV0PBfxC1+OLlM38eaGqdOZ/4sRdo3LKEzojNH7W7UZYt5h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(2616005)(1076003)(26005)(83380400001)(82960400001)(38100700002)(86362001)(36756003)(316002)(54906003)(8936002)(8676002)(4326008)(5660300002)(41300700001)(66476007)(66556008)(66946007)(2906002)(6506007)(6666004)(6512007)(478600001)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?hBLFTflFB6JrcMoYTFqstjBhtGiN?= =?utf-8?q?qbrMXDeMmI4Y9KhtxyMzErdBIBCIlSbLR0JG0aw64ewnM/ne1k7LC29IpgvRIaF8W?= =?utf-8?q?l/ykZyruBebfI9t+cVy8dibhe223s9BALHOWhpiPe0iDJkIQXsTsNRQRuCoVcLAVY?= =?utf-8?q?1EboHQiblrDHCFwcW4RlVDlSPYKzKn5B553oFDVINGV3V4mN+UKD75byGIKqNXMLQ?= =?utf-8?q?lWdO3vOqpyXIaCH8rkPWB+lVjdmA2R/PMR6h/ABlOOq5Ua0lh39GTAPrdHb905IyE?= =?utf-8?q?Di6e4AiDYGxrvUPKzYH9T+o7TjENF48BIr01ETG8Jo+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Fs?= =?utf-8?q?1eItNnBrkTRoG5+HbSXbcnixO1khe1PJnH8gKN5n/PYoqw5T1spreR2xrVY0Rh+3D?= =?utf-8?q?7B3UU+PmEexIBJ/um1fVo+1bacXn/mbVjMMb5w8gJRCsjtHCje8GqeGww3gwAFRNe?= =?utf-8?q?x6qNNW7liHXojpSRwl6M2O9ZYmEKqb3CUcGydNMHrK7qUyV7rLy51rUx0XJK13Wqn?= =?utf-8?q?HRZKEWmSlXB5ffpOGyNHA8/VITFHgtvSSD6+Dl3jaY+T1iU2AGPQg+0VxVQuok9/K?= =?utf-8?q?x2qLMfmn45avwLwrS6dzsDqJKUniOxg+FQ7/ZJPdpauzOY3nyTjjx5aaa5G106o2O?= =?utf-8?q?W44wprwZeAyXGdBunyzMi5BsHhhn542yVA=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: H1euBT4c99p9ay2kHMIzQ6h+09Fu/mx5lEH77kqivGbqoh+GGctlWxC5UngnkXIXeGuopuAnHkZeHunyUGO237jthAdwIpJAJV31Uz1RggYHDvbcLMo9Gc+PsYfVcjz5q9BiymK36UEXOmWhIIT8viRaOl2jByrsZILliBU/CbJTcdo2IQINIZq4/Emb4U6Wp6//WetpQum2mG66YP46YlLWDt2PL3WlCe0JxdnE5LAJQwARUAWyWEb8ZDbq7T0v9Hiqxou9nwpsfbvbzcerAVmrPIPxJM7r6+F392sfn6TXbWsxFNNip5oVPLcP7ZQds7z7AFVT5P27R05W/ITkmZbCPgOXyQMYR77XLWZ7xfUN8yYcLjb84FM3oLjn12tS9PPDrMf/4gHRSVXPw02RpFi37vvKvDNmLNw8AjFCq68/uW1IM+AUqfZzcXDNZDMaF3IbdKPTNwfUMdhVKzJoOtrmSztLukzYcbGmMvHLoiLj5ocfYOVhZkWEuSiZxPU3QLVJPf9GO6d+8IcPyC8zQjhi2cjgZqSIXzHcP80aHgn/bkU6AHbQ0Qot5KOT/xGGuN3tKOo3Kjuozxgp7psQl4Wr+YhRJNpPl0NxIVwXHqE6Swf1AQCPYtgaMVlt1jQG7CwN2rrAJhlUjRQpEIwFsF5CfEtyOrQa3LKBtHcFnoAGw6KpdZJtq597qqCJ8HvEaPXuNH3VUJvTMeWEWbtjm+XbzuLmeX7d1gdyWV+YyJh61qb/mAV+MidA2yta4UJ0CrX4cPuOSRyK+LIJo0u2vLaAyAuRhqj3Z2ahpzycFG0AteyHYAylHfVPXZqTRaS1sGNWPP3BwP5qACViYbvw0cqu1uo2W0sYkf1AEyeysAv6GnNZm7xk8nv2I10+hjtW X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: cabc543f-6554-49b9-086b-08dbc359ff6d X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:12:31.0178 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qkzwDUZkHyJ1XUGDogiMvfKgprQhUNqO6fpeLF+QVGVQmWtaCWGQJUDlnwY1lYtIqQneUvNFN3qFjX2jdwreWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR03MB6188 From: Jan Beulich The registration by virtual/linear address has downsides: At least on x86 the access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the area is inaccessible (and hence cannot be updated by Xen) when in guest-user mode. Introduce a new vCPU operation allowing to register the runstate area by guest-physical address. An at least theoretical downside to using physically registered areas is that PV then won't see dirty (and perhaps also accessed) bits set in its respective page table entries. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Acked-by: Julien Grall --- xen/arch/x86/x86_64/domain.c | 35 ++++++++++++++++++++++++++++++++ xen/common/domain.c | 39 ++++++++++++++++++++++++++++++++++++ xen/include/public/vcpu.h | 15 ++++++++++++++ 3 files changed, 89 insertions(+) diff --git a/xen/arch/x86/x86_64/domain.c b/xen/arch/x86/x86_64/domain.c index bfaea17fe718..494b0b54e64e 100644 --- a/xen/arch/x86/x86_64/domain.c +++ b/xen/arch/x86/x86_64/domain.c @@ -12,6 +12,22 @@ CHECK_vcpu_get_physid; #undef xen_vcpu_get_physid +static void cf_check +runstate_area_populate(void *map, struct vcpu *v) +{ + if ( is_pv_vcpu(v) ) + v->arch.pv.need_update_runstate_area = false; + + v->runstate_guest_area_compat = true; + + if ( v == current ) + { + struct compat_vcpu_runstate_info *info = map; + + XLAT_vcpu_runstate_info(info, &v->runstate); + } +} + int compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) { @@ -58,6 +74,25 @@ compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) break; } + case VCPUOP_register_runstate_phys_area: + { + struct compat_vcpu_register_runstate_memory_area area; + + rc = -EFAULT; + if ( copy_from_guest(&area.addr.p, arg, 1) ) + break; + + rc = map_guest_area(v, area.addr.p, + sizeof(struct compat_vcpu_runstate_info), + &v->runstate_guest_area, + runstate_area_populate); + if ( rc == -ERESTART ) + rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih", + cmd, vcpuid, arg); + + break; + } + case VCPUOP_register_vcpu_time_memory_area: { struct compat_vcpu_register_time_memory_area area = { .addr.p = 0 }; diff --git a/xen/common/domain.c b/xen/common/domain.c index 747bf5c87a8d..486c1ae3f7f3 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1830,6 +1830,26 @@ bool update_runstate_area(struct vcpu *v) return rc; } +static void cf_check +runstate_area_populate(void *map, struct vcpu *v) +{ +#ifdef CONFIG_PV + if ( is_pv_vcpu(v) ) + v->arch.pv.need_update_runstate_area = false; +#endif + +#ifdef CONFIG_COMPAT + v->runstate_guest_area_compat = false; +#endif + + if ( v == current ) + { + struct vcpu_runstate_info *info = map; + + *info = v->runstate; + } +} + long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) { long rc = 0; @@ -2012,6 +2032,25 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) break; } + case VCPUOP_register_runstate_phys_area: + { + struct vcpu_register_runstate_memory_area area; + + rc = -EFAULT; + if ( copy_from_guest(&area.addr.p, arg, 1) ) + break; + + rc = map_guest_area(v, area.addr.p, + sizeof(struct vcpu_runstate_info), + &v->runstate_guest_area, + runstate_area_populate); + if ( rc == -ERESTART ) + rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih", + cmd, vcpuid, arg); + + break; + } + default: rc = -ENOSYS; break; diff --git a/xen/include/public/vcpu.h b/xen/include/public/vcpu.h index a836b264a911..9dac0f9748ca 100644 --- a/xen/include/public/vcpu.h +++ b/xen/include/public/vcpu.h @@ -110,6 +110,8 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_info_t); * runstate.state will always be RUNSTATE_running and * runstate.state_entry_time will indicate the system time at which the * VCPU was last scheduled to run. + * 3. New code wants to prefer VCPUOP_register_runstate_phys_area, and only + * fall back to the operation here for backwards compatibility. * @extra_arg == pointer to vcpu_register_runstate_memory_area structure. */ #define VCPUOP_register_runstate_memory_area 5 @@ -221,6 +223,19 @@ struct vcpu_register_time_memory_area { typedef struct vcpu_register_time_memory_area vcpu_register_time_memory_area_t; DEFINE_XEN_GUEST_HANDLE(vcpu_register_time_memory_area_t); +/* + * Like the respective VCPUOP_register_*_memory_area, just using the "addr.p" + * field of the supplied struct as a guest physical address (i.e. in GFN space). + * The respective area may not cross a page boundary. Pass ~0 to unregister an + * area. Note that as long as an area is registered by physical address, the + * linear address based area will not be serviced (updated) by the hypervisor. + * + * Note that the area registered via VCPUOP_register_runstate_memory_area will + * be updated in the same manner as the one registered via virtual address PLUS + * VMASST_TYPE_runstate_update_flag engaged by the domain. + */ +#define VCPUOP_register_runstate_phys_area 14 + #endif /* __XEN_PUBLIC_VCPU_H__ */ /* From patchwork Mon Oct 2 15:11:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4ACA8E784BC for ; Mon, 2 Oct 2023 15:27:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611673.951222 (Exim 4.92) (envelope-from ) id 1qnKp0-0002dX-Ti; Mon, 02 Oct 2023 15:26:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611673.951222; Mon, 02 Oct 2023 15:26:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKp0-0002dQ-Ot; Mon, 02 Oct 2023 15:26:58 +0000 Received: by outflank-mailman (input) for mailman id 611673; Mon, 02 Oct 2023 15:26:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKbH-0001wY-Pj for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:47 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 235d5713-6136-11ee-9b0d-b553b5be7939; Mon, 02 Oct 2023 17:12:45 +0200 (CEST) Received: from mail-bn1nam02lp2045.outbound.protection.outlook.com (HELO NAM02-BN1-obe.outbound.protection.outlook.com) ([104.47.51.45]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:12:40 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by PH0PR03MB6680.namprd03.prod.outlook.com (2603:10b6:510:b8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Mon, 2 Oct 2023 15:12:37 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:12: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: 235d5713-6136-11ee-9b0d-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259565; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ISEr4708eEwbI3KjLaRXRXqE7bGvsZ1eF/8NLrTQb+w=; b=huMNTENRjU57cQQW1AMrils2MTHUbL3gWoRqQbP+US/WARSMXJr0iPZ+ VgHCRuDMCljiTLzo29Z7AXaovmGAaGSlbxNmJLz8cRcmxH78JpMx1CfgK 3RH6n2q8sI/sJ4haJcm8EfTeIrNbS7lc/JIVS8AcWzoVjqKLwxTg1MydC Y=; X-CSE-ConnectionGUID: EThC2Pw1SM+Pq+xJ5JBmVQ== X-CSE-MsgGUID: bcCHyozXS4KaOg4WvcpTGQ== X-IronPort-RemoteIP: 104.47.51.45 X-IronPort-MID: 123016651 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:XVvm86JGMkjTNITLFE+RCpQlxSXFcZb7ZxGr2PjKsXjdYENS0mcCn zRMWj+GaamJazD8eIx3boyy9ksFvpPTx9ExSgVlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAhk/nOHvylULKs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrYwP9TlK6q4mhB5gRkPakjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5aPWFlr 8QHcQsoLSiaxPKUnZCRT9dV05FLwMnDZOvzu1lG5BSBV7MMZ8mGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dupTSOpOBy+OGF3N79YNuFSN8Thk+Fj mnH4374ElcRM9n3JT+tqyj33raRw36iMG4UPLez3d57h0+j/TAwAToZCWSlquGFpXfrDrqzL GRRoELCt5Ma5EGtC9XwQRC8iHqFpQIHHcpdFfUg7wOAwbaS5ByWbkAEQzhbeZo5vck5bTUw0 xmCmNaBLT5lvaCRSHmd3qyJtj70Mi8QRUcdYQcUQA1D5MPsyKkxkxbOQ9BLAKOzyNrvFlnY2 CuWpSIzg7ESi88j1Kih+13DxTW2qfD0ohUd4wzWWiev6Fp/bYv9PYiwswCHsLBHMZqTSUSHs D4cgc+C4esSDJaL0iuQXOEKG7Lv7PGAWNHBvWNS81Aa32zF0xaekUp4uVmS+G8B3h44RALU IronPort-HdrOrdr: A9a23:Bhuvq6NHWMNAzcBcTsWjsMiBIKoaSvp037BL7SxMoHluGfBw+P rAoB1273HJYVQqOE3I6OrgBEDoexq1n/NICOIqTNSftWfdyQ+VBbAnwYz+wyDxXw3Sn9Qtsp uIqpIOauEY22IK6PrH3A== X-Talos-CUID: 9a23:8hRE6GnzKgGtZc9ay+adNyhAc1LXOVDhzFyKG1DhMkMqcKTWWX3N2olhrfM7zg== X-Talos-MUID: 9a23:K4lArQw3M77h7+Xaes4WGthnBwCaqK6lI2Acloc2gJWnPAt/ZwiDhyyLbbZyfw== X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="123016651" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B6kI5LCSU2srIB1HfXrjCwMEFt0JS9nLmfA1cIRT+6xhDABP383HQxmxSxIBdhaM6DmqSNOTom9+bxwxgB3K1awH46/52wU3fkzJWTxKsbAnmK8HQ9QeuPYDj3YZCa4eGNrvw0CdMSGIq4KXKypRDLkFNbfCv7IvL6fc8qOBUBhJB8bcoigiB3ZqyCEx0Ha7rA304Cp3potgLgh2SDOH8314FY+uE6/phbMwfqXHpN1pz6ny3qJtc+qIYzcI1ya7tTv2Xav0aQAAi52TKkhn7da5MiFTQ59ZkhGAvKEYz5I/C8iL/zJ3evPiEn/uZumyUmAVF0nWjQSKNFxoTWNhbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7m2lah6wFlfwWH+A26m4qMx9JvqC1q31TDTiVbHZVwE=; b=JhK6fpJM+kTBKRt29lBa9ROx2IP1RZ7LSji2ioJPzDfmlAZ2ENl6FUHLEezNwJZjvq9LeBf+4w15i79gQJAV8qbur8SEKFMoGW179RtxnZJYGVdOVSUiThyCoKXygRaX8kMDn5w5nDC0MdyRmNGe+r//qQQBQ8BIbwZidYq6WvD5zFJaDrE2ARcBlXqxb8Sr2o1LfmHe6n12ey0bTyRgFelAlWdWvPp2aabeMC1IPKf7m0/NfN5C4lLANqtWcSbF3qgqeOT9L9uvYFH0xsOkyC/VcT0tIgycplRUIwvobrIxjpSw+qnL2+qN6KjDed1QLVMxpk6Eoog7EBjvh8FUyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7m2lah6wFlfwWH+A26m4qMx9JvqC1q31TDTiVbHZVwE=; b=sIWT0N62ft08A98pBrp+A/jb5otBpQgG4f1t/qdf+lcXKG4X82VmOGlildttBJPiId5ribSoCiFyssKMBcmbA/4ncLKVFxCRfiCux13XmdznJfrJT9mkNuQAKX3CQvNs2XjN6K26f9oQgj+WbbqSMTdUJfyzvh8C4RhWCP0WWX8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v5 09/10] x86: introduce GADDR based secondary time area registration alternative Date: Mon, 2 Oct 2023 17:11:26 +0200 Message-ID: <20231002151127.71020-10-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0612.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:314::6) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|PH0PR03MB6680:EE_ X-MS-Office365-Filtering-Correlation-Id: 64533fec-d3b2-4872-8c6a-08dbc35a0307 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /nFX61vIBpa8OF5B51IvTc6x5Q0bxZiK66nBTbZZCU5BWhcbk/pRi+X1n4LhlWK5AorC1MNjpWVHivSqKeDbMFk0iFXOlqzyNZfC5R3LKO0AQ3r6SSsSqVRHROd+8uOexGOVvKgMBmTPXoUh4mzWAAkcMHyRaO7Ui6STVH3zXK5rAL3PQNQjEz1aJZ4utH4dACFppcdYuySD/5aNBUUE/tJjlfioyfAwZyW/xbshGrh0VTRMqblxzkpLPnif9JdTfdoxg+ksIglEv9YKpDgJBImP7nNtDiVpdHykNWH8Y6hJ6cWYY5C+K2jwD5Q4l89ZJIAr1ApqlH6Aw80z/jzObP8dmGIul8IDBfGQd5sOWal1vmaoKvVyvD2T1e9gIe2k+wAG9tc2ckGFvY9AZ0uPgd6KZUDlTSIvXJVJ4ei6W0vCDhFHdM2VlqeqLjqoK5aJQTmgwYS1e1Q11MdyxguHBhX0V6wXYLPPwDXSJgr2LjXWBS9aY7UaL40wtjgicoGoyS8c3GfVBEkh2b6KdhOkDyp7t03/qv1p9A2cbTyXA/DtOJZ1sKGhFciCd9/19dtt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(366004)(396003)(346002)(136003)(39860400002)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(36756003)(2906002)(26005)(478600001)(4326008)(8676002)(8936002)(6666004)(6486002)(6512007)(6506007)(83380400001)(2616005)(1076003)(41300700001)(316002)(54906003)(66556008)(66476007)(66946007)(5660300002)(38100700002)(86362001)(82960400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/cd4zj24L+TYFyaCkxhwDlUEqQ0+?= =?utf-8?q?9dFf4rCI6cnUvmuXz8cKiOp1w2XGbki8AAigCDArzuQg8bEgtt0uTcD0QlfnBDwGb?= =?utf-8?q?hHGn7/KA6ZRLXJMCrsSOTy+FeSNSMFtpC3NWwg4PFmJo8Gy2WsxWcgTY8RimiBS+a?= =?utf-8?q?1boH51ENRKiyM1h9XnG5ltJ8uTXmxI6LBu5hWn5DKJvBhUcV9P8WSif+MXTVCFpOp?= =?utf-8?q?87nq5R4KqKgt7O/LSSikotUhWrcNGp8B7ku4+8ZpA5SNKN3iHGIaAqBPDDQnuC+1d?= =?utf-8?q?7MubteHZiIUFm5Y4bamWlcEItrdkf3V0YGHZ9+wAZRiqfKSam1lJPlcl4/dT3w+bj?= =?utf-8?q?MzFeVPBOzucMDFS+jSyEAZ86hfWBzWs9cdHP+SngL9HNZmwusfD/aEzC/dVImw2V9?= =?utf-8?q?mdPbnc3vlWY+a3jFy6r3SPO8Bqj5RBX7C1zg5o8q0so3yxquN/PH0XugWFpOXdekx?= =?utf-8?q?8Sj3NYBB4GnTW4dp9SvLJS5e3uy9JrGrkapQ0PA5/HwAKYK34t2VKJTSiVVQqfDfC?= =?utf-8?q?X4ZTaup1mwaH3RbFLtWGyvZssRqwhcdNKhc3TYGLJia6AEoyCisqTzgIJVuEoEOZr?= =?utf-8?q?jVy6Bz1g/Z2HiomZ7gBnFySJ1fsXZWkLJaTBZK05hnkGHLCCWwAhdE+LjvFO54cLX?= =?utf-8?q?Faldtc2yfv7vI3W5VfND4MfjmNetkk/rJ8ZOkjhVYzVDZ24Wvx8pV94sBTqD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Data-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Y9nBoyHWajCiTn9EZ3PIX/lCb2YF/XDZXan2x4PdTMIMDfR06hOKYt3u6xaYdmeUTUjxAUKXPzRa98FYjg+QjiVyJVjL/gSzTFY8N0XV0ADJXJa6r/ZnNOaemwC8d1rZ8j/yY2lSwPpL58RewNWl5/t/nfBUXCx5TtRM150WlL6V3EHOTASbsb183Acffaq+aRJnJzj5XJC3CVUsHd1GoVtRlmHcBZookppVCgq6mAoizsHX7eGOOFfB+sPY3g7zCBPIpuoH0qdVEilE8orbifRmddMKDGbAbxNYvz6Sx3WLOTkYCVLGuTvMhdOS3F4+z1AMZ1hpn5HDCGCgl5Ql0bqIkKtAvNVzU7eQQI2LuXmg1DNiVwbxNbMn0ynqfYtHeTXHdfG1s2pFuFqJA6Rh8hllcad81e2rH7VrH2ND+PVq6fxFt67CugfWWC6bQ8UfMSmAqPnA8d8FquEbbGpphTWcbJYb/YrYAoHBkveTFtKdcccuhrFPhb9sa1/NFZz/bOQ9Ka2z4syvUNKjV2n7xl9pEj1Muns2RWMlzvS41RYcZ6JSb9BnsAJbHufY2WTsDdXmkhdLRveXnCR13x6I1HCzpIv/iiuUuzQpfUSAeZ6hXanV9KyoYDnMu09KkhOqc1wRkXBey1eOk6JPUkXIPB36wv91Cv10j9hoI+rN3kT5fsgHjyxENhLpz6l7lwthmSaIfBSOT5d73HuX67k14kOkR/PkL1QTVI6ya1WB7xrltWqeMDxFMTvwR8M3VhZ1jNBnQ3P+/cvKeBf6pGnIxXiUaX8CwX9nmw9YDXEU3GwpjJwUokOaMqJDUwwaIyrzmqb+1FR/sUMS6wlpEpwH+aREPOFcej4BtAAoagcbdhIazIcrb9rYS+QD1buBxs87 X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64533fec-d3b2-4872-8c6a-08dbc35a0307 X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:12:37.0561 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: m9tow9Svx7jXfQE2ndqbaUEWA1ca68dugLABnDYk91/hrfHf7oGIkvxnlGjfNo5XZzjTDHzL40mtsl6Fa+/V9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR03MB6680 From: Jan Beulich The registration by virtual/linear address has downsides: The access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the area is inaccessible (and hence cannot be updated by Xen) when in guest-user mode. Introduce a new vCPU operation allowing to register the secondary time area by guest-physical address. An at least theoretical downside to using physically registered areas is that PV then won't see dirty (and perhaps also accessed) bits set in its respective page table entries. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Acked-by: Julien Grall --- xen/arch/x86/domain.c | 28 ++++++++++++++++++++++++++++ xen/arch/x86/include/asm/domain.h | 2 ++ xen/arch/x86/time.c | 10 ++++++++++ xen/arch/x86/x86_64/domain.c | 1 + xen/include/public/vcpu.h | 4 ++++ 5 files changed, 45 insertions(+) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 9d352defa25e..8e0af2278104 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1529,6 +1529,15 @@ int arch_vcpu_reset(struct vcpu *v) return 0; } +static void cf_check +time_area_populate(void *map, struct vcpu *v) +{ + if ( is_pv_vcpu(v) ) + v->arch.pv.pending_system_time.version = 0; + + force_update_secondary_system_time(v, map); +} + long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) { long rc = 0; @@ -1567,6 +1576,25 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) break; } + case VCPUOP_register_vcpu_time_phys_area: + { + struct vcpu_register_time_memory_area area; + + rc = -EFAULT; + if ( copy_from_guest(&area.addr.p, arg, 1) ) + break; + + rc = map_guest_area(v, area.addr.p, + sizeof(vcpu_time_info_t), + &v->arch.time_guest_area, + time_area_populate); + if ( rc == -ERESTART ) + rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih", + cmd, vcpuid, arg); + + break; + } + case VCPUOP_get_physid: { struct vcpu_get_physid cpu_id; diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index e0bd28e424e0..619e667938ed 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -692,6 +692,8 @@ void domain_cpu_policy_changed(struct domain *d); bool update_secondary_system_time(struct vcpu *, struct vcpu_time_info *); +void force_update_secondary_system_time(struct vcpu *, + struct vcpu_time_info *); void vcpu_show_registers(const struct vcpu *); diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 332d2d79aeae..73df1639a301 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1628,6 +1628,16 @@ void force_update_vcpu_system_time(struct vcpu *v) __update_vcpu_system_time(v, 1); } +void force_update_secondary_system_time(struct vcpu *v, + struct vcpu_time_info *map) +{ + struct vcpu_time_info u; + + collect_time_info(v, &u); + u.version = -1; /* Compensate for version_update_end(). */ + write_time_guest_area(map, &u); +} + static void update_domain_rtc(void) { struct domain *d; diff --git a/xen/arch/x86/x86_64/domain.c b/xen/arch/x86/x86_64/domain.c index 494b0b54e64e..a02d4f569ee5 100644 --- a/xen/arch/x86/x86_64/domain.c +++ b/xen/arch/x86/x86_64/domain.c @@ -115,6 +115,7 @@ compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) case VCPUOP_send_nmi: case VCPUOP_get_physid: + case VCPUOP_register_vcpu_time_phys_area: rc = do_vcpu_op(cmd, vcpuid, arg); break; diff --git a/xen/include/public/vcpu.h b/xen/include/public/vcpu.h index 9dac0f9748ca..8fb0bd1b6c03 100644 --- a/xen/include/public/vcpu.h +++ b/xen/include/public/vcpu.h @@ -209,6 +209,9 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_get_physid_t); * segment limit). It can then apply the normal algorithm to compute * system time from the tsc. * + * New code wants to prefer VCPUOP_register_vcpu_time_phys_area, and only + * fall back to the operation here for backwards compatibility. + * * @extra_arg == pointer to vcpu_register_time_info_memory_area structure. */ #define VCPUOP_register_vcpu_time_memory_area 13 @@ -235,6 +238,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_register_time_memory_area_t); * VMASST_TYPE_runstate_update_flag engaged by the domain. */ #define VCPUOP_register_runstate_phys_area 14 +#define VCPUOP_register_vcpu_time_phys_area 15 #endif /* __XEN_PUBLIC_VCPU_H__ */ From patchwork Mon Oct 2 15:11:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13406369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CDB9E784BC for ; Mon, 2 Oct 2023 15:21:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.611638.951191 (Exim 4.92) (envelope-from ) id 1qnKjL-0006rC-IZ; Mon, 02 Oct 2023 15:21:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 611638.951191; Mon, 02 Oct 2023 15:21:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKjL-0006r5-Fg; Mon, 02 Oct 2023 15:21:07 +0000 Received: by outflank-mailman (input) for mailman id 611638; Mon, 02 Oct 2023 15:21:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qnKbK-0001wY-Nj for xen-devel@lists.xenproject.org; Mon, 02 Oct 2023 15:12:50 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 25683fcb-6136-11ee-9b0d-b553b5be7939; Mon, 02 Oct 2023 17:12:48 +0200 (CEST) Received: from mail-dm6nam10lp2106.outbound.protection.outlook.com (HELO NAM10-DM6-obe.outbound.protection.outlook.com) ([104.47.58.106]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2023 11:12:46 -0400 Received: from MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) by BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.28; Mon, 2 Oct 2023 15:12:43 +0000 Received: from MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f]) by MW4PR03MB6428.namprd03.prod.outlook.com ([fe80::ddbc:172e:c4a3:ec6f%4]) with mapi id 15.20.6813.035; Mon, 2 Oct 2023 15:12:43 +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: 25683fcb-6136-11ee-9b0d-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1696259568; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=M5aez5rTFO1GcCEIbyWKBylmYkINX0+kBsuOD8esuJs=; b=BYMcWqLtIVgXXy2yoNejAGe+RDPStvEOdm3rG7gTPDb7AWKRPKUJL4rr +kNAVTdFikM/zyA/9cLD61R8zWGzBnM6mInSAgFPiwQ1JLvRZezxaiWUC QFRTaSAuEvZugduONv7uxb93fpFxm9hDSmEpGF026pLfFdVyW1jrqXYQs 4=; X-CSE-ConnectionGUID: FfrCwBCfS+WA7M+9Ex6pVg== X-CSE-MsgGUID: RXbDzZ0qSWiHNEwZIFbhMw== X-IronPort-RemoteIP: 104.47.58.106 X-IronPort-MID: 123016667 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:c2gaVq4aXtYG0AATmD9QawxRtMnGchMFZxGqfqrLsTDasY5as4F+v jcbW2zTMv6LMGD8KNlyPYS//UwGucOGztE1TQU/qitkHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRG/ykTraCY3gtLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9lU355wehBtC5gZlPKgT5geH/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5m2 /ICAy8nRR64xN2fn5f4G8R82NwdI5y+VG8fkikIITDxK98DGMiGb4CUoNhS0XE3m9xEGuvYa 4wBcz1zYR/cYhpJfFAKFJY5m+TujX76G9FagAvN+exrvC6OnEooiOaF3Nn9I7RmQe1PmUmVv CTe9nnRCRAGLt2PjzGC9xpAg8eWx3ijAdxMSuLQGvhCum2Z6n4hUAQtalqbh9SmuG+QUdJ6N BlBksYphe1onKCxdfHtUhv9rHOasxo0X9tLD/Z8+AyL0rDT4QuSGi4DVDEpQNwrstUnAyMj0 FChlsnsQzdotdW9S3iQ67OVpjOaIjUOICkJYipsZRQBy8nupsc0lB2nZtR+FK+4iPXlFDe2x CqFxAAlnKkah8MP06S9/HjEjiiqq5yPSRQ6ji3LV2es9StlZ4qoYYO55Fyd5vFFRLt1VXGEt XkA3sSbsuYHCMjVkDTXGb1TWra0+/yCLTvQx0Z1GIUs/Cis/Hjlep1M5DZ5JwFiNcNslSLVX XI/cDh5vPd7VEZGp4cuC25tI6zGFZTdKOk= IronPort-HdrOrdr: A9a23:eXu8K6GmunLwH0YQpLqE7MeALOsnbusQ8zAXPiFKJSC9F/byqy nAppsmPHPP5gr5OktBpTnwAsi9qBrnnPYejLX5Vo3SPzUO1lHYSL1K3M/PxCDhBj271sM179 YGT0GmMqyTMbGtt7ee3DWF X-Talos-CUID: 9a23:H4+nMGudeBVQZjEBFPtkxXAS6IsLfGf20137LXT7Nk82bf7EZE/O4J1rxp8= X-Talos-MUID: 9a23:Tg3LXAxcBFlDaV1Uxz6Zpl8xLBGaqJ6eAmwfo80fgPaFFQpdJAW8oj63Z5Byfw== X-IronPort-AV: E=Sophos;i="6.03,194,1694750400"; d="scan'208";a="123016667" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K7gP98FmDvxEZR9AXljjEsXv4sCfAhk6acHtKbHfxOsFnOMZy2+D1PdizlgoeTc24qY1EqnLaFBGQh8W47O4YTiyHy3S7f1NKvA+f5v7ptCFI4i5yqYjod4y2yAHstEn2OOozFB26FiGNhIrZAk8kYhG425+hC8tHTq+PyZuCP3Bs457VsPmtvuiQLMwvnZ61aNV3gz1zfjzS7istGxt6OJXpDg5jP8VTiJOJTlVND4LctfZaT6LdzLaTTGKctqVYRvnysrwDny5tRvf8ceEVMUFbEMljj2vqz7Z4r/ZLK1+JgK5bZCeKfy+ER/J2CoEODmkctFb2evKVCBvJ5Rnmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GQo4moAla6ceZD4asYRXJVxG0xoZsU0KKz3b6MGdn7Y=; b=bLsdfpYphoyKNWpH8hH2+HpMucYaCMuJ4BMrd4shm6oGjFEYUqL8qsd5elAX/ZbiwcS2/lW+SUXi/ARN3hxq0Db07jHeJpsaEPffJtRDC039qYKjKxrA303nccO7CYdeipD+mHJkhMJ8n3qKQ+DhSTzymnjf+JhsDOi35AWjxum9VBiFx8YIjJIGWupSU2RP4C1/0ZOcpOv7VbR8EtbFLlwrb7V/0S4f93SfnEh3QOQL3Y8aR8+WTp5n3R5cDZQcQ7CMmavCrJMjTCJ9AaPkewDWZfCP4jzJqstTaPAg4+U6a7RGSpU8sdXB69tJoiHtnAD3/SeevzqdJDe53UBIRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GQo4moAla6ceZD4asYRXJVxG0xoZsU0KKz3b6MGdn7Y=; b=HuP51X/sGh8XUvd9Nd/a+lbCDwdFG5WWAmql7oHvqxCb9aFslea53Xv6DERsHAtxbt2I6DQMvWlBcJoEfdp5ZczcO/B7EzpStaMxFF/yJlno80QOgy51DLE5/gnl1FocgiC0K0PpUTGkoY397O43UoO4VW6fDRQYt57QJ3Gy93Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org, henry.wang@arm.com Cc: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini , Tamas K Lengyel Subject: [PATCH v5 10/10] common: convert vCPU info area registration Date: Mon, 2 Oct 2023 17:11:27 +0200 Message-ID: <20231002151127.71020-11-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231002151127.71020-1-roger.pau@citrix.com> References: <20231002151127.71020-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0320.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:197::19) To MW4PR03MB6428.namprd03.prod.outlook.com (2603:10b6:303:123::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR03MB6428:EE_|BN9PR03MB6188:EE_ X-MS-Office365-Filtering-Correlation-Id: afd83ff3-dc1a-44ff-ec75-08dbc35a067b X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G57wTZ1WuyOBN8gewh/nw3IL39EtjNdSLqVNu7IG7vqCn+6lFMf/9x+yMNQnDOagnh580z3gbgLYS75fRR4tlNx1XLOyUA3lH45I1cX2LkDYTtexnGT/0flFipPggEfUNf/HVqsRiqjQDWGn1LRqEBHg/pCaLSy0ceqvuUHBAkSbbsBdp4C9e2bPSlUzqAmX9Ap2E4bQ4wVh9XJOu6k1hSeJ4lVYn7l/5grZ0VPHVozZ+gLRC3xx1kPTqSUY50p/bAcP3zG4lXXaJyjo5kQj4Zo8kpBbNe3zqUhlu1PIfztvzOXCJcOfQRJimQTFN/qF6oiqDriBaVqrqeY5KcUczdpPiSlMtaZl8KHEuGzcb/0We5Kfa1BfeK6SYXMzCS2Tjzk+pCvhQWkOx2og6UiBvoTRpnYSywJqF0o9h06NtZsc4teHlceJ8SIDzo6eY7+JoYq9rKkrgYtWDWHbcvY/VtuO7s6byY2M+hZJLB2DE3cG/xdt9toBR3MuDrM2MBVXqw5btgTJDAB4sF9sYgVKamgB9UvEEkZzLNGzlUUgVKlaAsrnOLJCL3JXq70L+vjAslwQ1lv88OymjzvxTdqqrsyvvum8DdzhXXjEMB+FKAeMMgHpGT/WfT/RQzrK3xT+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR03MB6428.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(2616005)(1076003)(26005)(83380400001)(82960400001)(38100700002)(86362001)(36756003)(316002)(54906003)(8936002)(8676002)(4326008)(5660300002)(41300700001)(66476007)(66556008)(66946007)(30864003)(2906002)(6506007)(7416002)(6666004)(6512007)(478600001)(6486002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?FhDjrS1y2c1xjq3Y8S6Qv7BohA69?= =?utf-8?q?SOoIheyFq48nKXJpHUZBK8TMs7aAQusODTaxgwuF1kvOT2qhYAZoxA++6SIiZpwJe?= =?utf-8?q?zUhv+vQ2hOgSR2kxEn8swkb1UNqKLOjlBXzJads1G+eNVaQeew7JVwm90DHbu4Bef?= =?utf-8?q?MtbG++ys8HMJz4u8OaRvmxwCjf52pw6sNAy1ClJOpM4zPjCszld7D/sFZ0UXBYkZZ?= =?utf-8?q?XeTrqBdKckf0vLnGVnXclHh/UJ+gVVFNsU+QT/+wDqvufypmu4xWK4xNeU6zUJFmN?= =?utf-8?q?bwtx4t4wlVDmMrBHyaECxyZUM7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Tl1zSPuhKiFpDcyw90yFmIxC/L4ZF3VwyMPnpb0RrV/rqB0ZMiByZELvkZusPFVTW0WkYfZCr9+hgyay8AVeV3eu572umyJwiRNA3HLKmoBfjP+m4lRNiAnTaaAIis7vmB7l5Jo4E+55mqLd1+vKC5Pnh3qhqYLBYcJiHMOv2+xlnXOc2qN0N3n8bKFCjkuD9O8Uw5ZbLOBkzfBnoJpm6PdXnleNTJF+CeRvmfUMuavaWENuUHPiuSiNsoWsjZ4enI9co8Fzjzh6Q34QUtCXfABouZS2wNo9lkubCHTirh/M93f6pRo10CzAGX3hsPRN1ZcLqUDt5mBRka7ARON6RmvJQXOYQSomUA13EovCtkNIr/OTobP5oLLjrq5ZK9/mB1k0jI8WXCnE/XJCQ= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: afd83ff3-dc1a-44ff-ec75-08dbc35a067b X-MS-Exchange-CrossTenant-AuthSource: MW4PR03MB6428.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2023 15:12:43.1126 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GmvT/V2p7WFtkhuJfhpjQKnoyezqdWK1jfV5lSpDqNZr9415IYxyHBasABMYWUdm6l8IVRbAsw6NbiJuv4enFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR03MB6188 From: Jan Beulich Switch to using map_guest_area(). Noteworthy differences from map_vcpu_info(): - remote vCPU-s are paused rather than checked for being down (which in principle can change right after the check), - the domain lock is taken for a much smaller region, - the error code for an attempt to re-register the area is now -EBUSY, - we could in principle permit de-registration when no area was previously registered (which would permit "probing", if necessary for anything). Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Acked-by: Julien Grall --- xen/arch/x86/include/asm/shared.h | 19 ++- xen/arch/x86/mm/mem_sharing.c | 20 ++- xen/arch/x86/pv/shim.c | 2 +- xen/arch/x86/time.c | 2 +- xen/arch/x86/x86_64/asm-offsets.c | 2 +- xen/arch/x86/x86_64/traps.c | 2 +- xen/common/compat/domain.c | 2 +- xen/common/domain.c | 204 ++++++++++++------------------ xen/include/xen/domain.h | 3 - xen/include/xen/sched.h | 5 +- xen/include/xen/shared.h | 3 +- 11 files changed, 112 insertions(+), 152 deletions(-) diff --git a/xen/arch/x86/include/asm/shared.h b/xen/arch/x86/include/asm/shared.h index dd3ae8c2639d..60b67fa4b427 100644 --- a/xen/arch/x86/include/asm/shared.h +++ b/xen/arch/x86/include/asm/shared.h @@ -26,17 +26,20 @@ static inline void arch_set_##field(struct domain *d, \ #define GET_SET_VCPU(type, field) \ static inline type arch_get_##field(const struct vcpu *v) \ { \ + const vcpu_info_t *vi = v->vcpu_info_area.map; \ + \ return !has_32bit_shinfo(v->domain) ? \ - v->vcpu_info->native.arch.field : \ - v->vcpu_info->compat.arch.field; \ + vi->native.arch.field : vi->compat.arch.field; \ } \ static inline void arch_set_##field(struct vcpu *v, \ type val) \ { \ + vcpu_info_t *vi = v->vcpu_info_area.map; \ + \ if ( !has_32bit_shinfo(v->domain) ) \ - v->vcpu_info->native.arch.field = val; \ + vi->native.arch.field = val; \ else \ - v->vcpu_info->compat.arch.field = val; \ + vi->compat.arch.field = val; \ } #else @@ -57,12 +60,16 @@ static inline void arch_set_##field(struct domain *d, \ #define GET_SET_VCPU(type, field) \ static inline type arch_get_##field(const struct vcpu *v) \ { \ - return v->vcpu_info->arch.field; \ + const vcpu_info_t *vi = v->vcpu_info_area.map; \ + \ + return vi->arch.field; \ } \ static inline void arch_set_##field(struct vcpu *v, \ type val) \ { \ - v->vcpu_info->arch.field = val; \ + vcpu_info_t *vi = v->vcpu_info_area.map; \ + \ + vi->arch.field = val; \ } #endif diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 99cf001fd70f..6f1ce1623b8d 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1705,7 +1705,6 @@ static int copy_vpmu(struct vcpu *d_vcpu, struct vcpu *cd_vcpu) static int copy_vcpu_settings(struct domain *cd, const struct domain *d) { unsigned int i; - struct p2m_domain *p2m = p2m_get_hostp2m(cd); int ret = -EINVAL; mfn_t vcpu_info_mfn; @@ -1717,17 +1716,14 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d) if ( !d_vcpu || !cd_vcpu ) continue; - /* Map in the vcpu_info page if the guest uses one */ - vcpu_info_mfn = d_vcpu->vcpu_info_mfn; - if ( !mfn_eq(vcpu_info_mfn, INVALID_MFN) ) - { - ret = map_vcpu_info(cd_vcpu, mfn_to_gfn(d, vcpu_info_mfn), - PAGE_OFFSET(d_vcpu->vcpu_info)); - if ( ret ) - return ret; - } - - /* Same for the (physically registered) runstate and time info areas. */ + /* + * Map the vcpu_info page and the (physically registered) runstate and + * time info areas. + */ + ret = copy_guest_area(&cd_vcpu->vcpu_info_area, + &d_vcpu->vcpu_info_area, cd_vcpu, d); + if ( ret ) + return ret; ret = copy_guest_area(&cd_vcpu->runstate_guest_area, &d_vcpu->runstate_guest_area, cd_vcpu, d); if ( ret ) diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index f08b16bae2fe..81e4a0516d18 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -383,7 +383,7 @@ int pv_shim_shutdown(uint8_t reason) for_each_vcpu ( d, v ) { /* Unmap guest vcpu_info page and runstate/time areas. */ - unmap_vcpu_info(v); + unmap_guest_area(v, &v->vcpu_info_area); unmap_guest_area(v, &v->runstate_guest_area); unmap_guest_area(v, &v->arch.time_guest_area); diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 73df1639a301..d0b0986509b2 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1542,7 +1542,7 @@ static void __update_vcpu_system_time(struct vcpu *v, int force) struct vcpu_time_info *u = &vcpu_info(v, time), _u; const struct domain *d = v->domain; - if ( v->vcpu_info == NULL ) + if ( !v->vcpu_info_area.map ) return; collect_time_info(v, &_u); diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c index fbd6c54188db..57b73a4e6214 100644 --- a/xen/arch/x86/x86_64/asm-offsets.c +++ b/xen/arch/x86/x86_64/asm-offsets.c @@ -53,7 +53,7 @@ void __dummy__(void) OFFSET(VCPU_processor, struct vcpu, processor); OFFSET(VCPU_domain, struct vcpu, domain); - OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info); + OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info_area.map); OFFSET(VCPU_trap_bounce, struct vcpu, arch.pv.trap_bounce); OFFSET(VCPU_thread_flags, struct vcpu, arch.flags); OFFSET(VCPU_event_addr, struct vcpu, arch.pv.event_callback_eip); diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index f4d17b483032..e03e80813e36 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -96,7 +96,7 @@ static void _show_registers( if ( context == CTXT_hypervisor ) printk(" %pS", _p(regs->rip)); printk("\nRFLAGS: %016lx ", regs->rflags); - if ( (context == CTXT_pv_guest) && v && v->vcpu_info ) + if ( (context == CTXT_pv_guest) && v && v->vcpu_info_area.map ) printk("EM: %d ", !!vcpu_info(v, evtchn_upcall_mask)); printk("CONTEXT: %s", context_names[context]); if ( v && !is_idle_vcpu(v) ) diff --git a/xen/common/compat/domain.c b/xen/common/compat/domain.c index c4254905359e..7ff238cc2656 100644 --- a/xen/common/compat/domain.c +++ b/xen/common/compat/domain.c @@ -49,7 +49,7 @@ int compat_common_vcpu_op(int cmd, struct vcpu *v, { case VCPUOP_initialise: { - if ( v->vcpu_info == &dummy_vcpu_info ) + if ( v->vcpu_info_area.map == &dummy_vcpu_info ) return -EINVAL; #ifdef CONFIG_HVM diff --git a/xen/common/domain.c b/xen/common/domain.c index 486c1ae3f7f3..b8281d7cff9d 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -127,10 +127,10 @@ static void vcpu_info_reset(struct vcpu *v) { struct domain *d = v->domain; - v->vcpu_info = ((v->vcpu_id < XEN_LEGACY_MAX_VCPUS) - ? (vcpu_info_t *)&shared_info(d, vcpu_info[v->vcpu_id]) - : &dummy_vcpu_info); - v->vcpu_info_mfn = INVALID_MFN; + v->vcpu_info_area.map = + ((v->vcpu_id < XEN_LEGACY_MAX_VCPUS) + ? (vcpu_info_t *)&shared_info(d, vcpu_info[v->vcpu_id]) + : &dummy_vcpu_info); } static void vmtrace_free_buffer(struct vcpu *v) @@ -993,7 +993,7 @@ int domain_kill(struct domain *d) return -ERESTART; for_each_vcpu ( d, v ) { - unmap_vcpu_info(v); + unmap_guest_area(v, &v->vcpu_info_area); unmap_guest_area(v, &v->runstate_guest_area); } d->is_dying = DOMDYING_dead; @@ -1448,7 +1448,7 @@ int domain_soft_reset(struct domain *d, bool resuming) for_each_vcpu ( d, v ) { set_xen_guest_handle(runstate_guest(v), NULL); - unmap_vcpu_info(v); + unmap_guest_area(v, &v->vcpu_info_area); unmap_guest_area(v, &v->runstate_guest_area); } @@ -1496,111 +1496,6 @@ int vcpu_reset(struct vcpu *v) return rc; } -/* - * Map a guest page in and point the vcpu_info pointer at it. This - * makes sure that the vcpu_info is always pointing at a valid piece - * of memory, and it sets a pending event to make sure that a pending - * event doesn't get missed. - */ -int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned int offset) -{ - struct domain *d = v->domain; - void *mapping; - vcpu_info_t *new_info; - struct page_info *page; - unsigned int align; - - if ( offset > (PAGE_SIZE - sizeof(*new_info)) ) - return -ENXIO; - -#ifdef CONFIG_COMPAT - BUILD_BUG_ON(sizeof(*new_info) != sizeof(new_info->compat)); - if ( has_32bit_shinfo(d) ) - align = alignof(new_info->compat); - else -#endif - align = alignof(*new_info); - if ( offset & (align - 1) ) - return -ENXIO; - - if ( !mfn_eq(v->vcpu_info_mfn, INVALID_MFN) ) - return -EINVAL; - - /* Run this command on yourself or on other offline VCPUS. */ - if ( (v != current) && !(v->pause_flags & VPF_down) ) - return -EINVAL; - - page = get_page_from_gfn(d, gfn, NULL, P2M_UNSHARE); - if ( !page ) - return -EINVAL; - - if ( !get_page_type(page, PGT_writable_page) ) - { - put_page(page); - return -EINVAL; - } - - mapping = __map_domain_page_global(page); - if ( mapping == NULL ) - { - put_page_and_type(page); - return -ENOMEM; - } - - new_info = (vcpu_info_t *)(mapping + offset); - - if ( v->vcpu_info == &dummy_vcpu_info ) - { - memset(new_info, 0, sizeof(*new_info)); -#ifdef XEN_HAVE_PV_UPCALL_MASK - __vcpu_info(v, new_info, evtchn_upcall_mask) = 1; -#endif - } - else - { - memcpy(new_info, v->vcpu_info, sizeof(*new_info)); - } - - v->vcpu_info = new_info; - v->vcpu_info_mfn = page_to_mfn(page); - - /* Set new vcpu_info pointer /before/ setting pending flags. */ - smp_wmb(); - - /* - * Mark everything as being pending just to make sure nothing gets - * lost. The domain will get a spurious event, but it can cope. - */ -#ifdef CONFIG_COMPAT - if ( !has_32bit_shinfo(d) ) - write_atomic(&new_info->native.evtchn_pending_sel, ~0); - else -#endif - write_atomic(&vcpu_info(v, evtchn_pending_sel), ~0); - vcpu_mark_events_pending(v); - - return 0; -} - -/* - * Unmap the vcpu info page if the guest decided to place it somewhere - * else. This is used from domain_kill() and domain_soft_reset(). - */ -void unmap_vcpu_info(struct vcpu *v) -{ - mfn_t mfn = v->vcpu_info_mfn; - - if ( mfn_eq(mfn, INVALID_MFN) ) - return; - - unmap_domain_page_global((void *) - ((unsigned long)v->vcpu_info & PAGE_MASK)); - - vcpu_info_reset(v); /* NB: Clobbers v->vcpu_info_mfn */ - - put_page_and_type(mfn_to_page(mfn)); -} - int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size, struct guest_area *area, void (*populate)(void *dst, struct vcpu *v)) @@ -1662,14 +1557,44 @@ int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size, domain_lock(d); - if ( map && populate ) - populate(map, v); + /* No re-registration of the vCPU info area. */ + if ( area != &v->vcpu_info_area || !area->pg ) + { + if ( map && populate ) + populate(map, v); - SWAP(area->pg, pg); - SWAP(area->map, map); + SWAP(area->pg, pg); + SWAP(area->map, map); + } + else + rc = -EBUSY; domain_unlock(d); + /* Set pending flags /after/ new vcpu_info pointer was set. */ + if ( area == &v->vcpu_info_area && !rc ) + { + /* + * Mark everything as being pending just to make sure nothing gets + * lost. The domain will get a spurious event, but it can cope. + */ +#ifdef CONFIG_COMPAT + if ( !has_32bit_shinfo(d) ) + { + vcpu_info_t *info = area->map; + + /* For VCPUOP_register_vcpu_info handling in common_vcpu_op(). */ + BUILD_BUG_ON(sizeof(*info) != sizeof(info->compat)); + write_atomic(&info->native.evtchn_pending_sel, ~0); + } + else +#endif + write_atomic(&vcpu_info(v, evtchn_pending_sel), ~0); + vcpu_mark_events_pending(v); + + force_update_vcpu_system_time(v); + } + if ( v != current ) vcpu_unpause(v); @@ -1699,7 +1624,10 @@ void unmap_guest_area(struct vcpu *v, struct guest_area *area) domain_lock(d); map = area->map; - area->map = NULL; + if ( area == &v->vcpu_info_area ) + vcpu_info_reset(v); + else + area->map = NULL; pg = area->pg; area->pg = NULL; domain_unlock(d); @@ -1830,6 +1758,27 @@ bool update_runstate_area(struct vcpu *v) return rc; } +/* + * This makes sure that the vcpu_info is always pointing at a valid piece of + * memory, and it sets a pending event to make sure that a pending event + * doesn't get missed. + */ +static void cf_check +vcpu_info_populate(void *map, struct vcpu *v) +{ + vcpu_info_t *info = map; + + if ( v->vcpu_info_area.map == &dummy_vcpu_info ) + { + memset(info, 0, sizeof(*info)); +#ifdef XEN_HAVE_PV_UPCALL_MASK + __vcpu_info(v, info, evtchn_upcall_mask) = 1; +#endif + } + else + memcpy(info, v->vcpu_info_area.map, sizeof(*info)); +} + static void cf_check runstate_area_populate(void *map, struct vcpu *v) { @@ -1859,7 +1808,7 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) switch ( cmd ) { case VCPUOP_initialise: - if ( v->vcpu_info == &dummy_vcpu_info ) + if ( v->vcpu_info_area.map == &dummy_vcpu_info ) return -EINVAL; rc = arch_initialise_vcpu(v, arg); @@ -1990,16 +1939,29 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) case VCPUOP_register_vcpu_info: { struct vcpu_register_vcpu_info info; + paddr_t gaddr; rc = -EFAULT; if ( copy_from_guest(&info, arg, 1) ) break; - domain_lock(d); - rc = map_vcpu_info(v, info.mfn, info.offset); - domain_unlock(d); + rc = -EINVAL; + gaddr = gfn_to_gaddr(_gfn(info.mfn)) + info.offset; + if ( !~gaddr || + gfn_x(gaddr_to_gfn(gaddr)) != info.mfn ) + break; - force_update_vcpu_system_time(v); + /* Preliminary check only; see map_guest_area(). */ + rc = -EBUSY; + if ( v->vcpu_info_area.pg ) + break; + + /* See the BUILD_BUG_ON() in vcpu_info_populate(). */ + rc = map_guest_area(v, gaddr, sizeof(vcpu_info_t), + &v->vcpu_info_area, vcpu_info_populate); + if ( rc == -ERESTART ) + rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih", + cmd, vcpuid, arg); break; } diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index a6b22fa2cac8..54d88bf5e34b 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -80,9 +80,6 @@ void cf_check free_pirq_struct(void *); int arch_vcpu_create(struct vcpu *v); void arch_vcpu_destroy(struct vcpu *v); -int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned int offset); -void unmap_vcpu_info(struct vcpu *v); - int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size, struct guest_area *area, void (*populate)(void *dst, struct vcpu *v)); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 6e1028785d8c..3609ef88c4ff 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -176,7 +176,7 @@ struct vcpu int processor; - vcpu_info_t *vcpu_info; + struct guest_area vcpu_info_area; struct domain *domain; @@ -289,9 +289,6 @@ struct vcpu struct waitqueue_vcpu *waitqueue_vcpu; - /* Guest-specified relocation of vcpu_info. */ - mfn_t vcpu_info_mfn; - struct evtchn_fifo_vcpu *evtchn_fifo; /* vPCI per-vCPU area, used to store data for long running operations. */ diff --git a/xen/include/xen/shared.h b/xen/include/xen/shared.h index a411a8a3e38d..5b71342cab32 100644 --- a/xen/include/xen/shared.h +++ b/xen/include/xen/shared.h @@ -44,6 +44,7 @@ typedef struct vcpu_info vcpu_info_t; extern vcpu_info_t dummy_vcpu_info; #define shared_info(d, field) __shared_info(d, (d)->shared_info, field) -#define vcpu_info(v, field) __vcpu_info(v, (v)->vcpu_info, field) +#define vcpu_info(v, field) \ + __vcpu_info(v, (vcpu_info_t *)(v)->vcpu_info_area.map, field) #endif /* __XEN_SHARED_H__ */