From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85C31C433ED for ; Wed, 5 May 2021 19:55:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59E7E613C9 for ; Wed, 5 May 2021 19:55:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233603AbhEET4w (ORCPT ); Wed, 5 May 2021 15:56:52 -0400 Received: from mail-dm6nam12on2061.outbound.protection.outlook.com ([40.107.243.61]:64992 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230437AbhEET4v (ORCPT ); Wed, 5 May 2021 15:56:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K7pI1/MEo8nRYa/1AJ6LlB73p83elML1Xdb1E1KM/QNlN5KjwBS0nrFKRwGdwtq+/NFq/mQWbEi3oEyX1mUBP89kuponmWpYJofYV2mr+1AKbUNa4wXyL062mxyAPgufhwFjGISxeEuVWnN4Gutz+JOyKOiKcozhumVKMoh4EvAeIhkAIA99m5Gk4KHzQUFRGBV2kbHBemEMKt8xCYlYEA7Qg/HFI1LA+Wr75WBCHvpXVcI69j/nGFWVb6Osp+YsFp2YXfKXDTjeu4C49B4owFC98Op1lF5ymEEnddD9NQZ3FOQoxc8i5pGqkNP32r+oBuSqGZP8CJb//9zpejSWaw== 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-SenderADCheck; bh=jf7dMnLAhAvOoyvn3VAI5mAjKpw1QbLDxRURKvMsyJE=; b=NTDdn4Drllcsk/klc2ETg/n8PRBYLaU57oXi46Rp1CFefaNCJ/kk/lR012VuO34T+KIkNQPMV2kkuKOY4jn8396/KLKJIfvhixQC8LW69QuYLoBZSPkzpPGVgcXasLWpUDfLRA1V7qhxSrSMoCCIwWtkdBAuEtSH1NvQbfPT18lvkZXxxri6ZXuIUuHjP7XNzFuGNzTHlNdfLXufvsB1DbKfDWwCQnjM4gPv05Z/UkqaTxLb9IChjj3HSQrH/ilBKSlTMuhAvrOUQj3x+P+eCJmEBH+7UZOT0CImWDzlcZ5hBNm0hZQqZ6LXhZAapgCBLSqssBy6B2v+w09BEndqtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=jf7dMnLAhAvOoyvn3VAI5mAjKpw1QbLDxRURKvMsyJE=; b=LN2W5JU/BgPmGvadNtM1inEfI6hDOryeiJXmDSRV/4pQtMGgT0T+Wj4tZOEE3jw6iIMJdToI7qaiPoGoZZs69ai+WyA9Zxrd1PJrg9ZB9PQpsyd+TeOWEYg3fXmnw4rwdOJJnBg5IKchVcxTU7qXEE3oxAfseNWGgF1PA0IV8v0= Authentication-Results: alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM5PR12MB1353.namprd12.prod.outlook.com (2603:10b6:3:76::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.40; Wed, 5 May 2021 19:55:52 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::b914:4704:ad6f:aba9]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::b914:4704:ad6f:aba9%12]) with mapi id 15.20.4087.044; Wed, 5 May 2021 19:55:52 +0000 Subject: Re: SRCU dereference check warning with SEV-ES To: Paolo Bonzini , kvm list Cc: Borislav Petkov References: <601f1278-17dd-7124-f328-b865447ca160@amd.com> <9bbc82fa-9560-185c-7780-052a3ee963b9@amd.com> From: Tom Lendacky Message-ID: <1d0ddadc-6a98-2564-aa78-cf8fa2113a28@amd.com> Date: Wed, 5 May 2021 14:55:50 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN4PR0501CA0047.namprd05.prod.outlook.com (2603:10b6:803:41::24) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.236.30.118] (165.204.77.1) by SN4PR0501CA0047.namprd05.prod.outlook.com (2603:10b6:803:41::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.8 via Frontend Transport; Wed, 5 May 2021 19:55:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7c04459-c468-4c17-3a7d-08d90fffc990 X-MS-TrafficTypeDiagnostic: DM5PR12MB1353: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b7ERQWKQfzWYl/IwsZw8urZTGHgZujmeXMT0NCA0kpDAEeJIY8SavCgwqBmYC2R2c2RAnKDovRMSjA16eVyi/PzzTRXTZq40gDAsIviH8WJocW35cRojp/BZ1IKpbEi4SH+IX6QQeMmYNBD0ccnFKn4vCgdlftkrhM49Olsz2oMopMXI3QviV0kkMgptVgZcs5JsbxFqAcgwVxcEaH6q70OwwqLoCnL6LAvJlGWyns8M+EV+CkzWNGCHFnxdKARqqBNgRKy2ISDq4e7e5nmnDYMUemkStekmMatb8Z+LEXjRIkU3crf+SgvQkAwLVW4xaLIePpSwHW+3tmkXfSMGo6aEKcsLgXM89oW+IeEVTZXMK4jUAUCZqRRjhWyFj8WsepnPCR4JRBGLnEmC0fJEKs6UPaYS060SfFIaWZ638gXPsfTQpb4oKmQFYXx8U8EsUch6m0+P+3bT5Futu5dx7Gsqux6SuGlA4Ppk3vvRp5SLMTlmErT617EFTFE01eHym4ffS+SKezf2KGK1sUVOijYG2A6zHbt11kBnIflJCq52Hb1bieMrURsshHv3zdAyJa98hbyiMAlMbanOd2Cl4Gx4XrVVTiK57FJ+IxhCf7cHfy/QjfAkpfv4KegBcM7YuS5krgUCGCWRPTH+f8juXeGsPqhlmPlQ1KmdGG/2oqg+FKBLZyISoOSNMITMbOnM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(366004)(376002)(136003)(396003)(346002)(38100700002)(31686004)(2906002)(316002)(4326008)(86362001)(8676002)(53546011)(26005)(16576012)(956004)(31696002)(16526019)(66476007)(66946007)(478600001)(83380400001)(5660300002)(6486002)(66556008)(8936002)(2616005)(36756003)(110136005)(186003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-Mess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hR4e2w5/w9Fbq0/?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7c04459-c468-4c17-3a7d-08d90fffc990 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 19:55:52.3585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +BQUErbUfCQAagJPYEX15/JlGPOHkSyk1zCthKuaHKs6r6B3wCr3aOnQOvCHL1tWXQwhJoLtQU6/pd41UkhMSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1353 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 5/5/21 1:50 PM, Paolo Bonzini wrote: > On 05/05/21 20:39, Tom Lendacky wrote: >> On 5/5/21 11:16 AM, Paolo Bonzini wrote: >>> On 05/05/21 16:01, Tom Lendacky wrote: >>>> Boris noticed the below warning when running an SEV-ES guest with >>>> CONFIG_PROVE_LOCKING=y. >>>> >>>> The SRCU lock is released before invoking the vCPU run op where the >>>> SEV-ES >>>> support will unmap the GHCB. Is the proper thing to do here to take the >>>> SRCU lock around the call to kvm_vcpu_unmap() in this case? It does fix >>>> the issue, but I just want to be sure that I shouldn't, instead, be >>>> taking >>>> the memslot lock: >>> >>> I would rather avoid having long-lived maps, as I am working on removing >>> them from the Intel code.  However, it seems to me that the GHCB is almost >>> not used after sev_handle_vmgexit returns? >> >> Except for as you pointed out below, things like MMIO and IO. Anything >> that has to exit to userspace to complete will still need the GHCB mapped >> when coming back into the kernel if the shared buffer area of the GHCB is >> being used. >> >> Btw, what do you consider long lived maps?  Is having a map while context >> switching back to userspace considered long lived? The GHCB will >> (possibly) only be mapped on VMEXIT (VMGEXIT) and unmapped on the next >> VMRUN for the vCPU. An AP reset hold could be a while, though. > > Anything that cannot be unmapped in the same function that maps it, > essentially. > >>> 2) upon an AP reset hold exit, the above patch sets the EXITINFO2 field >>> before the SIPI was received.  My understanding is that the processor will >>> not see the value anyway until it resumes execution, and why would other >>> vCPUs muck with the AP's GHCB.  But I'm not sure if it's okay. >> >> As long as the vCPU might not be woken up for any reason other than a >> SIPI, you can get a way with this. But if it was to be woken up for some >> other reason (an IPI for some reason?), then you wouldn't want the >> non-zero value set in the GHCB in advance, because that might cause the >> vCPU to exit the HLT loop it is in waiting for the actual SIPI. > > Ok.  Then the best thing to do is to pull sev_es_pre_run to the > prepare_guest_switch callback. A quick test of this failed (VMRUN failure), let me see what is going on and post back. Thanks, Tom > > Paolo >