From patchwork Mon Jun 20 23:14:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 12888548 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5B02C433EF for ; Mon, 20 Jun 2022 23:15:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 785938E0007; Mon, 20 Jun 2022 19:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 734A08E0003; Mon, 20 Jun 2022 19:15:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D6858E0007; Mon, 20 Jun 2022 19:15:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4E7FE8E0003 for ; Mon, 20 Jun 2022 19:15:13 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 15422F8B for ; Mon, 20 Jun 2022 23:15:13 +0000 (UTC) X-FDA: 79600172106.31.9343CB9 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2053.outbound.protection.outlook.com [40.107.220.53]) by imf05.hostedemail.com (Postfix) with ESMTP id 871B110000D for ; Mon, 20 Jun 2022 23:15:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TI4jTXVvxsFPh3i0Wo+pfh5JClWS8tCA1O4X3+7v/oz94dyURCqMQhTK5QbyOD6tGj18ivcKZnVre25E2xUE1kH3jloaJIYwy/xElLm3OfemiCcbNirWT8hC4w3xEachhEeXwU5eBy8hUpTqbYpYz7rWsfFdTzOB+W/sFFFjNiGPyeCOKjBqzgQa2xirTz+/b2IUV8R1wOZJcA9VJRyM6Ont9kzCRq92pG1x2rOv6UmsZZOR446sOTQXxeG6RUcndAjM+A/sEnUJ+4iOWwf5yWhlA7neZWH0FdVDste0TEvd+B9shIh8iQN7VruCr1rXD1c1jW/+z3tVZGNXwj9dIg== 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=/J8G0bfp4LWOx/OjRjyKoVZ4QH5t7Fdin9D8BEx40LM=; b=aeNJ25ZmrtWes2oTtmFCedfSrPdG5MQTZaIK1uVSjNdPm552Wt8PjL7gAdqpcJDjs/Xdu3DLyPIrz1Q1Sf2FScehgXuVSG3G1D7sioVtMdZle+INn30vgXB4I1AlVgK9XEB/5omNQNuga96oLWuRv6+sLLF6gEckhFoffHlzSbZc9j40ZfY8qi22tiScNPbVT21ZJGAXHAf7kTZDZ0CAynzAtZK/rTIZ5Y/uLjepOEMoaCHnxO34BF2Ee0Mg2ziNb840K5Sj8+J6A7Xy7GEP/OQKeKAhEgRB8g+WMsoy08oq5Na/2Ba3peWciOTzuMaohEZ4Flwo9DwK5toiE8YGkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/J8G0bfp4LWOx/OjRjyKoVZ4QH5t7Fdin9D8BEx40LM=; b=xqnZltMtPBGwZ+Vxj8/QMQRFOAXN+XX0JwVtmXf0Dy8qc1h0ndtr+ogehTXp6cbIkX2mvvvQtES3JVB8MQWmKJzw4aGRcWtzNpYxAekiFKhO7tFyOdXthVbSpwoypoK77CuAxP6tBwXf5xQcuS/AEEHrbS7xsAoQVKdMh64Kxb4= Received: from DM6PR21CA0029.namprd21.prod.outlook.com (2603:10b6:5:174::39) by MN2PR12MB3549.namprd12.prod.outlook.com (2603:10b6:208:107::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.14; Mon, 20 Jun 2022 23:15:09 +0000 Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::75) by DM6PR21CA0029.outlook.office365.com (2603:10b6:5:174::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.3 via Frontend Transport; Mon, 20 Jun 2022 23:15:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT064.mail.protection.outlook.com (10.13.172.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5353.14 via Frontend Transport; Mon, 20 Jun 2022 23:15:09 +0000 Received: from ashkalraubuntuserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 20 Jun 2022 18:15:06 -0500 From: Ashish Kalra To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH Part2 v6 47/49] *fix for stale per-cpu pointer due to cond_resched during ghcb mapping Date: Mon, 20 Jun 2022 23:14:58 +0000 Message-ID: <1dbc14735bbc336c171ef8fefd4aef39ddf95816.1655761627.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e5c9583-bab6-42fc-d8bd-08da5312b83c X-MS-TrafficTypeDiagnostic: MN2PR12MB3549:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5zr4TgVMeWsk1I9Qnj0sKNbkr7XPFZMOGSTvhqSeCFcLdF9IAp3LeYLY33HInXu+A6Go4PLy9hg38KqQ5je16LUM3Cmfk3vKQ+U5FxLLRcPWdCySilpnWWezZCyayVVnW3UyTIpUmFd0Yu7NEB1cH0AxOKGSTpS56xw20oE6e2EBfq4IfLp/ozGJstNGXrxwz9opnMAQ18qfF+lcOxvIFQbzTDsiL9TjgsjyMmHNd7GqnV/l7K1+MwxkrLnnPQqPsvYudfW3CGbJhoznS8xc9z41/fOyP0+s7M+4jyyMVF9UeK0rAvqe2K4H+f3qgOW2jOZ37fkW2fXdV4a8Fbb7+A5clQ7JHCCOFI7xhyb5RYFwFdZh3U+1zqKnjOaqTcL2gnGtcbD980dViyj3Wh04oNSvGzmaRPc6zBHCJ4qEuO+wW5+OE63sV93OJZHQTfh7xUK4o2ggo1Pm168CqWr2ShuvpPRYb6z8NbLddHTF25OrRpAG98m2eKQqb/co6DxYGHU6mPN7NSxDO7bWV2oWF2dscj+5Pmzykdl0Jh8clsSyaQI3n34Ngi+QaPPHnWCHIiK3YponlHnHoXzgs2XnpwW6bQ9Bg1GCP3kUEE5J+ff76NS5ViAhfXSu9SrA5X5lDvlXBWNCRbmwmGUAuLMa3hUjFkrVoaY8EuDJxGqhBUMGo5KFsu2d2VHPQh5dYJbz9Z3TAnMyb6Vnwj/bFMnTjGJd0CupFdMROfpPvZg1/zFhtXuBJ3tPSeURCHHo1q9f/WwJc/FgIEZ1/Cby/Vh7JA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(136003)(396003)(39860400002)(376002)(346002)(46966006)(36840700001)(40470700004)(4326008)(7696005)(54906003)(47076005)(110136005)(86362001)(40460700003)(26005)(2906002)(70206006)(8676002)(356005)(70586007)(82740400003)(7416002)(186003)(426003)(316002)(5660300002)(8936002)(478600001)(7406005)(16526019)(36860700001)(83380400001)(2616005)(41300700001)(81166007)(40480700001)(336012)(82310400005)(36756003)(6666004)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2022 23:15:09.0921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e5c9583-bab6-42fc-d8bd-08da5312b83c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3549 ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1655766912; a=rsa-sha256; cv=pass; b=okFfkX6ora/TkJZo8wExd+/qyR13nm//zmTqko8qRJxcPWpLbaco0n0Dom18gNOEDwjFT1 M5hU0i02r8P58xXWA9zqVt/JtMDkbzpFHcexb0Z4mToPMqNUpHw/aWH3T0tyuhZ14B/Arz LG4mjsk4Fx5YfzeqQpSd9wm5FYxjYGk= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=xqnZltMt; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf05.hostedemail.com: domain of Ashish.Kalra@amd.com designates 40.107.220.53 as permitted sender) smtp.mailfrom=Ashish.Kalra@amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655766912; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/J8G0bfp4LWOx/OjRjyKoVZ4QH5t7Fdin9D8BEx40LM=; b=eUaaMpM+C78wzLcIJFyu8YaeEF5L7GEidWyqdHoVrpMk2ljmE72XoPZ7/C84e/1B/c8n0q QTvKnh93NGdcgVk1wLKWc7of97MddGjedXcaKfqKcSZJSB+ftG2l80sDdJkuF2ej62faOc kSTnFkpnojYL+YdGClk3OLmNuiauMPU= Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=xqnZltMt; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf05.hostedemail.com: domain of Ashish.Kalra@amd.com designates 40.107.220.53 as permitted sender) smtp.mailfrom=Ashish.Kalra@amd.com X-Stat-Signature: qcay7xy39bwos36xz188ypiep7q7rg89 X-Rspamd-Queue-Id: 871B110000D X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1655766912-807613 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Michael Roth Signed-off-by: Michael Roth --- arch/x86/kvm/svm/svm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index fced6ea423ad..f78e3b1bde0e 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1352,7 +1352,7 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu) static void svm_prepare_switch_to_guest(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); - struct svm_cpu_data *sd = per_cpu(svm_data, vcpu->cpu); + struct svm_cpu_data *sd; if (sev_es_guest(vcpu->kvm)) sev_es_unmap_ghcb(svm); @@ -1360,6 +1360,10 @@ static void svm_prepare_switch_to_guest(struct kvm_vcpu *vcpu) if (svm->guest_state_loaded) return; + /* sev_es_unmap_ghcb() can resched, so grab per-cpu pointer afterward. */ + barrier(); + sd = per_cpu(svm_data, vcpu->cpu); + /* * Save additional host state that will be restored on VMEXIT (sev-es) * or subsequent vmload of host save area.