From patchwork Mon Jan 23 14:56:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13112325 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 E75FDC05027 for ; Mon, 23 Jan 2023 14:56:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.482973.748813 (Exim 4.92) (envelope-from ) id 1pJyFF-0007HZ-4u; Mon, 23 Jan 2023 14:56:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 482973.748813; Mon, 23 Jan 2023 14:56:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pJyFF-0007HS-21; Mon, 23 Jan 2023 14:56:25 +0000 Received: by outflank-mailman (input) for mailman id 482973; Mon, 23 Jan 2023 14:56:24 +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 1pJyFD-0007BS-Oo for xen-devel@lists.xenproject.org; Mon, 23 Jan 2023 14:56:23 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2062.outbound.protection.outlook.com [40.107.104.62]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 19d9b1c3-9b2e-11ed-91b6-6bf2151ebd3b; Mon, 23 Jan 2023 15:56:22 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AM9PR04MB8422.eurprd04.prod.outlook.com (2603:10a6:20b:3ea::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 14:56:21 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389%7]) with mapi id 15.20.6002.033; Mon, 23 Jan 2023 14:56:21 +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: 19d9b1c3-9b2e-11ed-91b6-6bf2151ebd3b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UUYbCZqUooZtUB5YodunRk27zv62PW646tNw5KgD5K6H8gTfDR7msNXifAFc0SndPlfu1oniUsnWKnvg6xN9AqouWyZ15v6yUSMmjky/ZrTPKQ/UoE+8giXyJznyaPQjELemw4p2qiSaDBaRDlne0/nH29jqM6iICm2RBte6aa32j3RTVdWau8H8lhA4rMtX7XibsqumGGgtvDDV82Bav3SsmYYg79vbxvaKEO6e4ZWlrdvG+ceMME2fk7ItwC184sQ77St7O5QW/lCZ9DhHG3fcu+x3xKAA2B9QvMEHo9LtBsoCImpwQtxFJ1SESdRSgKi/Jlilb+z4un6qxbECDw== 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=/fluMR14yPGtt1MEzvUXmnvLOAxRzJWqVCDdd15B6Z4=; b=dbnoMzSWC+4eWlIOSS9vvWJWSEMfj+fWsE7rat10qxMwXQ3NefCX3DDIRc3qmB63iPN5cocnHDlT5kcMQChzbXuXIaPcqIcIu2IbYXX87f5OlbW+SPsJSEf2JhhHpNibnLQIfSXkWeA9YEAgAujbGOTwZ1shcVChTHIuwA7GA7xmGHkImpHw72O4jN/3YzctlMzoWSXF/opycOhAFv70HEs/qNxiYGD3/pdNwqVXT4TIy15breVW12ps6lKex5dbrO+ni3O46B9X1yKyzU2vUfChXSQZaLlRSeuy1gcAP9EoBDApBJa176huCt9VnDAvxxzguFaBso7rEc5NCYFSLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/fluMR14yPGtt1MEzvUXmnvLOAxRzJWqVCDdd15B6Z4=; b=l/+qPrcOO6Xg5Wxh0yptKE0JiGUUPek//MwpraJgP1Isyo8PKsi2mosmG1AV0eu3ECrloWRHmhR6P0iqvIraqyjO/8qf8h7W8X2RBY1FOdd51gT+I1rfaG7eODDzJGUwySdJ8S7RuRshisqnUxla+3msNBe5hj5xUJ5rNhwOZGguWd0RiN1xZ3O0LmIPhMKG3FmN3Cyg5KppU4Q4vcDweyde8KBe6Rn6nUQgcSRPgFHlVkq9+b9qx3Zf/CZ+ZQfx89QP+EVPg2MCJjWv7CIYgdqObUHjccTaHDElgM/aSPSb2wjqstIqIKgw4G5CbbmVViMyqs9UAL970a7Nat+JJQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <97fe3de2-a647-ede6-1831-1e301976b83e@suse.com> Date: Mon, 23 Jan 2023 15:56:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: [PATCH v2 6/8] domain: introduce GADDR based runstate area registration alternative Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: <33cd2aba-73fc-6dfe-d0f2-f41883e7cdfa@suse.com> In-Reply-To: <33cd2aba-73fc-6dfe-d0f2-f41883e7cdfa@suse.com> X-ClientProxiedBy: FR0P281CA0038.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::21) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AM9PR04MB8422:EE_ X-MS-Office365-Filtering-Correlation-Id: 37c0268a-90b4-4562-ff05-08dafd51fd3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TjFcoZBjhsLCQDkM+4WZssqtmE8aESLJyXjjlauAXK3gx4ZDiSDhNjSObQDravJPLHu5BgoKAYvro1lR0OOZeTKQ6voNg3t6H6rW3JGjdz7ah0x7eLuDrpkOMJDdLNMsE9kjFkWHsqnz0bryTt7HkHRTMDprk2IneWW/crRACIDxvrW6FfPjTXTlh5HBmWV7j/s9tOhXm3QynipWXqzpOMOs/tbRP9r9fZZd43NJ8XM+QHplztPAUGtNvOuep1L49kBvdiaGY35HvyhpFlPBwmrIJ6gFDAvO8s5Wn7exOnOa2Gcbj089LCqsM6wgOSnCCBGXqnwFB3UXFNXSSbxMp3yPxaQ6bd3eGMpweOufhvjH5ujeKPNzsjHqlV7Z1DLGZEeL6z/sS4Nx8jyv07tkp50qMY5HQPvICwyYmcBYxHo5l9KOzZNtL540xxAOLYFxDF3j3psaDh6ayTeLFQu+GjiBv9gYUjgnMkBu5mPCkpnT1DaffsTPL3rtTDIKxLqTC5MIHLSXTxFgCxyVYdPKtZlcL13xjjtZINCLtOp/JaOua9m/B8pqBycgE+ERORVMGeEIfIIHJhV/IZayuzorIg197l4JD/lK//lGbEZccgeDuocxlBNVMePh4UPpHWGzAkmldabDdqR8lU50XB+tYGVV79th8p38T7gv6eEXLoNNZxYHAm2y/tMlS1MxkQo+yPpNjeVIzkd7nYxDTVx7mXmKmPa+LqiegpHzHwTcHOo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(396003)(136003)(39850400004)(366004)(346002)(451199015)(31686004)(2616005)(38100700002)(31696002)(41300700001)(2906002)(8936002)(5660300002)(4326008)(8676002)(6916009)(6506007)(316002)(54906003)(36756003)(83380400001)(66556008)(66476007)(66946007)(86362001)(478600001)(6486002)(26005)(186003)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?e0NPxr9ID9Jk+2o/ArRLdeVeQ3YH?= =?utf-8?q?DKgXbic7jiddXk266g3sWVKq9WOG721qkcccffBgAtEVWt3WFVYnmqwTZ9xYdAnzS?= =?utf-8?q?fvJmS+FDBUxxsM6SJeeu8AtdPlCmiN2iWq3Q8GDZYs+a1Rm8LRZgqrcVDspvTAqjb?= =?utf-8?q?iyL43Bkn+R4qNhZAzKRTmFHyuT4CN4wdPH+CL5uW/c8EMJbo6zjpB0D20y0IFZlxv?= =?utf-8?q?TEzqCZeicnuDzbMCz/5nNIVisJUd2IzKQaICOnsJdIbV2wEeWxx8MQB4009rkbf/6?= =?utf-8?q?I5mwEwqVuVIOV4ba1gP2dRti/xwnVB6WrPh/44Ck6EhOiGwbwUADRHKuMNJp9L5Tw?= =?utf-8?q?mQMyOrEPfernpA3V1BWhuB96sYWFVTIUDhqW8rhwcmat+NEGYbGTxUoR/fJiJA5dO?= =?utf-8?q?5Sr/Z4wS0W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l5vF3D3wQV/9iNQgnJ3kQbc8mqls5XT7GWDFfy5msqYWLG6yHfM3gyCOcO?= =?utf-8?q?PnxGyRNFbcEQw14SjpZ3B8gHDZbKumZjUUd5Qpa9ZapssyvBmysOE2doM1FEKiUhv?= =?utf-8?q?GXSgn/iyw4WmpSYSmfHZz59cq8+V4ChPtrYo7mSYRC1k4HEudXaGPYSItAmhgbH5K?= =?utf-8?q?A632vINXcYNBLcd6lCJFRu/HOkrLXVmAdwuA7mq37I7AXTumr6z7nsBNBwSlEnWR+?= =?utf-8?q?EeeUz1Y+w2y4?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37c0268a-90b4-4562-ff05-08dafd51fd3f X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 14:56:21.1073 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bpjL5HXUBmS6BTOABqsxSM5R2W3orsmx8uxX45BOTCQbGF5QiPXSmKtwim++UxUF6y4V2rXP6YEu/JGv3K9bSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8422 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 --- v2: Extend comment in public header. --- 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) { @@ -57,6 +73,25 @@ compat_vcpu_op(int cmd, unsigned int vcp 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: { --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1803,6 +1803,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; @@ -1977,6 +1997,25 @@ long common_vcpu_op(int cmd, struct vcpu 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; --- a/xen/include/public/vcpu.h +++ b/xen/include/public/vcpu.h @@ -218,6 +218,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__ */ /*