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-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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-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/+nAkb39btXtHu3VFLkquIEIoCR?= =?utf-8?q?SSEybj/SFQIM0M0r1Y/0dk7qEY/op/bCnQVSYxCDMRGZEyLMqokekMIewbIRT/xrF?= =?utf-8?q?cm/YKXKQW8AbXND3XCbbBZhokoK4PfPTXZKxoxibtEmUVKMqm/rMzfytHuv/DJo/v?= =?utf-8?q?t2lX2dfvgZicJoPDJzrCUreOiDGo2LCGxRXRAhSi70H+CaLlXrLyDprCNHKfwUFTI?= =?utf-8?q?APK8dJJNEl5uI7hY4SGBo/NHmDJxq+nCxcGoDzV9wcYWUAzXQJf/ekOzhHRG0f4nN?= =?utf-8?q?CooAp/W+FVm7lL+fG/3sK/yQP28uPV+sqjWTiRGJjv7YS+umfeGLqFBQudSclpb+Q?= =?utf-8?q?Jps1iHmpwnP/hW5gxCNdTOqAJt43iLi/zhvjh7wMSYw14Voxcd8rRkgwpDtPZkYKg?= =?utf-8?q?YNUBTibgZeIS1veki3mSQE4NLM8WsiTJIoRmVli6VVP+gLbA2b+HWiUAvH4xTnrJp?= =?utf-8?q?+aczL638HWvokTMpUjxthptLqXmwYiPt6FjjzE+SFNh2HN7WMmplpEqnGM6NLDQcP?= =?utf-8?q?hk/BPqBa6GyPj/G6lC1NgVuJHFquN6ZIsLHjg5jwJZcqxpKLHRxsydzcFxxzEx2nc?= =?utf-8?q?TO0ZNJrUIbDYjuuoXv3ayIkDbJUmpywtGRA6W/1OO1w63XU/N3wrM5c+Q+sGyvvxL?= =?utf-8?q?h31aOIvuDCrV?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nrp3AaXIguPWEEWFygW5hPYaBJIXg5obRusdCww3C9Krc+YnBvqLXZCuSeNvVVq0lAtDyYRsa9gwXmZzOJ1RfRhPZyB8n/bkIskwkkB5ycc6CJpMEO7ZBeWEP+UVqyzSXzpyRkv5njylnzKZd0+C5+lo4RJyri5FvYQjQzVPUodGfyPlC7iZ1rr9gFSZAE1zgudlB4RMsN9i/etxnKFFwn1uACeyM6ZaizLEZNTaIaXblWzWuzgCye73FTt2etOu2fIAswuaLshpOG0QW3LsPA+3y0V3vE1phq3TG1iwe4Wk4BnLQPYyjy1sbhjy+zd+EYUeDQdc/epzw7/8PB0VdyuIHv3nlXZwOR1Pr+ruCdeaY5HzLm97425yB+J/EuAfou7IYMreZMZ5eKXuLWfsZUGCXsCvAfzCORrfkPrjZtiIA7LIhpmgaGpUitMwRe6GFF3HOslYgqAJZwwM7WryN8aBxp+rwRMUhABra6Lf+Vny1Y3JJKvQuk55dLDDCKR5L+1KQEC4fxr0eZxyD2uILEqnbX9vmKY4r/ducd/hq8cjtU+hcgIpok1tjTvh8riwKxqLYQD4xaHCeFgCT6WPPZ9YTiNCFI7VQq9zPQDOJ5pyBBjunkIvoBe0xstxdnqIy73lN/XxsVX1P4V+Wfm7EvWkc6/itGquuBMTG5iccuuqO19YlZkvJTI7ARSNF7wFO5ZUA1i+5eDQwxCiqSBvttRbdwrN99wxkUlELDGeImSrFjUPpB61OcTOvfQ0mjxeXAXKO2KiWiWEONj7V+2kXZIKPh/LKnAJgMLF3AwOTIXjKHK8MqPXRmVRNTc/beQx5ZJgb4pB0rMmY0riN6pDrw== X-OriginatorOrg: citrix.com 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;