Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3666737pxb; Wed, 13 Oct 2021 10:25:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl3tX1DqFGJ2gs0B2+rKnyRQU1i0lJljOeGoYUdeqgQHrngmst+GbcW3+77HP0nx99DOjn X-Received: by 2002:a17:90a:db53:: with SMTP id u19mr14997807pjx.234.1634145909385; Wed, 13 Oct 2021 10:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634145909; cv=none; d=google.com; s=arc-20160816; b=GFMohvPQQ2mlcFBZK/IyNhGZl1VosNzSIe3N8LSV9QwcJ+PxQh5LNV9irRU0avbc4H 8EALSLmwzrmtg5cFZG7EgAFPEbV8p4qSIeVTyZf1+OmvYCo/NmxHOVkkXpeqXLsrZR6P S1L4aLC10r+QLrYJVb9sehD1dvhUv5FQ265rbOre2kFqeTZTnlOumuKu1bxtY+ekSxgQ 3S8WSj2JllP1HNYBy5DvmLOnLVx7DKnEtGkATnTAJz/05R73ml4LXwvvOu3Z92r1iCr8 FHybsmw5jQZKAh9lbbn2J60z+gT02002DeQ3C5DTExHk8U6eUCrv1OxqWdQHVycx+tdq yMFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=znXxY8k0yLhwBo4efWALoeW3xXIEX4hKO/JqS3b4Dyg=; b=zmna+7mLSGuDPInSn7SAceKTERedswJraUjn+T8UtWll16QkjjAU+sFgHsnSY2MXjS lfRNIGgqevfAhPSw1gSaTg6isFbnFL54umH7/5zy03NG2gwIMM23fK10gnmWkrU8ppV4 Wlg4j7rid4kGbtWns4K46CLWrAIWcNqTLuyc7SxOcmw2/I2FMM4n+hVWZoJW2Vj+1OUr 4HGv1lGuGOkCDJy+1+44RB3OGclxw3AhnfK/dEN46aVn9bCFqv667GESOY4YI1UxRV2N klHFCL8fI74JVa0jK5/lOgUY5KkD7Yiq+OJ4ta6jw5268INzxdM45F0Wp6BBe6IWzwNf uSlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Z6YEV8Co; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k8si136040pgl.527.2021.10.13.10.24.54; Wed, 13 Oct 2021 10:25:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Z6YEV8Co; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237511AbhJMR0w (ORCPT + 99 others); Wed, 13 Oct 2021 13:26:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbhJMR0w (ORCPT ); Wed, 13 Oct 2021 13:26:52 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABAAEC061570 for ; Wed, 13 Oct 2021 10:24:48 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id d13-20020a17090ad3cd00b0019e746f7bd4so4989286pjw.0 for ; Wed, 13 Oct 2021 10:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=znXxY8k0yLhwBo4efWALoeW3xXIEX4hKO/JqS3b4Dyg=; b=Z6YEV8Cobp8BBjd4T6EW5woNqLhuBZaG7SxbSekXJNyXJWRkz1azJSTu3gOp4dXKdO 4FBHrg/Domvx507fqMSOgFtt/Xv69x+Y84bt8auhTLLYQhJZOlaTd3wQmym3OaJKgtH+ WqkA5fvqnwNY6A6nZAFtPRp/4kAM3o0TS0Dn9QUKQzIlVAX0UqpyATB3bzmxjBik9hFC +KRZ3lxRKUFEnm2cWjd/yV1GyemnKu6e+fItC343CgRoKyestVhd5nxdLXR4grlSVLu4 l1EYljp0lpYLbg7qvECY8qrKHFYNObgOsbE8Hs5p/b6NJTjhEWVJ3wJT6EiFnMG5c2bo vfUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=znXxY8k0yLhwBo4efWALoeW3xXIEX4hKO/JqS3b4Dyg=; b=GTkId/irg1bAit76QK+T47BuQbNvrALwmtmdHEFnmJuAYAkpgCl87gvDzbkzOXDWKM VL9tq9CCD1FNLWr6mTuEK08bf9TYoqxj2wLDjVa75jBVzj/nONEvqo4PAk+YAoMqs76z Kz3QBoWdNwJUMk4Tfv42awmtA0sDXGQfKqSNiXUJUjsdtdRfCQRgh/G3mVlb5Yw+ukB+ d1WmzICkFL1kro3Q/8Iu3u20VPicBhIU96BdCcclT9O9yjKDNiwsP2fNpPgNFE7V/1+B Ql1PgRuxQhbD0FDmcTM1k6ERvcdtt2shoWYKwpSh8AcASAixlamqHSyTNben/QqmXaeq G0JA== X-Gm-Message-State: AOAM531IQmBFk3eAS1bwcbxOFC93P8ya1miDjQOthNyVNOjt1oMNAdch ybe/tKByQZM+5h67dZn/QrDXuw== X-Received: by 2002:a17:90b:782:: with SMTP id l2mr618878pjz.190.1634145887734; Wed, 13 Oct 2021 10:24:47 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id 14sm133224pfu.29.2021.10.13.10.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 10:24:47 -0700 (PDT) Date: Wed, 13 Oct 2021 17:24:43 +0000 From: Sean Christopherson To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH Part2 v5 37/45] KVM: SVM: Add support to handle MSR based Page State Change VMGEXIT Message-ID: References: <20210820155918.7518-1-brijesh.singh@amd.com> <20210820155918.7518-38-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Oct 13, 2021, Brijesh Singh wrote: > > The more I look at this, the more strongly I feel that private <=> shared conversions > > belong in the MMU, and that KVM's SPTEs should be the single source of truth for > > shared vs. private. E.g. add a SPTE_TDP_PRIVATE_MASK in the software available bits. > > I believe the only hiccup is the snafu where not zapping _all_ SPTEs on memslot > > deletion breaks QEMU+VFIO+GPU, i.e. KVM would lose its canonical info on unrelated > > memslot deletion. > > > > But that is a solvable problem. Ideally the bug, wherever it is, would be root > > caused and fixed. I believe Peter (and Marc?) is going to work on reproducing > > the bug. > We have been also setting up VM with Qemu + VFIO + GPU usecase to repro > the bug on AMD HW and so far we no luck in reproducing it. Will continue > stressing the system to recreate it. Lets hope that Peter (and Marc) can > easily recreate on Intel HW so that we can work towards fixing it. Are you trying on a modern kernel? If so, double check that nx_huge_pages is off, turning that on caused the bug to disappear. It should be off for AMD systems, but it's worth checking. > >> + if (!rc) { > >> + /* > >> + * This may happen if another vCPU unmapped the page > >> + * before we acquire the lock. Retry the PSC. > >> + */ > >> + write_unlock(&kvm->mmu_lock); > >> + return 0; > > How will the caller (guest?) know to retry the PSC if KVM returns "success"? > > If a guest is adhering to the GHCB spec then it will see that hypervisor > has not processed all the entry and it should retry the PSC. But AFAICT that information isn't passed to the guest. Even in this single-page MSR-based case, the caller will say "all good" on a return of 0. The "full" path is more obvious, as the caller clearly continues to process entries unless there's an actual failure. + for (; cur <= end; cur++) { + entry = &info->entries[cur]; + gpa = gfn_to_gpa(entry->gfn); + level = RMP_TO_X86_PG_LEVEL(entry->pagesize); + op = entry->operation; + + if (!IS_ALIGNED(gpa, page_level_size(level))) { + rc = PSC_INVALID_ENTRY; + goto out; + } + + rc = __snp_handle_page_state_change(vcpu, op, gpa, level); + if (rc) + goto out; + }