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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7ABDC433EF for ; Wed, 13 Oct 2021 17:24:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 84F5C610CC for ; Wed, 13 Oct 2021 17:24:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 84F5C610CC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 13A4F940008; Wed, 13 Oct 2021 13:24:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EA89900002; Wed, 13 Oct 2021 13:24:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECDD3940008; Wed, 13 Oct 2021 13:24:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id DED54900002 for ; Wed, 13 Oct 2021 13:24:49 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 833C22D248 for ; Wed, 13 Oct 2021 17:24:49 +0000 (UTC) X-FDA: 78692089098.01.F84C589 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf06.hostedemail.com (Postfix) with ESMTP id CD68E801A8A0 for ; Wed, 13 Oct 2021 17:24:48 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id lk8-20020a17090b33c800b001a0a284fcc2so4962564pjb.2 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=fQtqlwixiHxM4L9DCaTZqlgAg+IGG0TWw0A4TRDTCPGBIOxHawP0k3DOTKLzrwkena IvF9J4o4ha6B/yxFYm2djSoWUaGVVOQBCMd9IZzYX8Vlf563OZKDcIHm3VQFr2LqyjhE 1gJfVJoF1WIt5nXDBSa49tF2A/J9L0+RBBzjTa+vf7JEkxUKRMbILJTwIvxYEQqFkiCn qTnuex0gLica1bVqqc3mcyD8uT0rp3vE+FAnivMRfYl+Q6y1Sgush8s+GqqikE81yvmz VAPfuqaDsavewnUpGEogp/CIWjyjShi44+u1yfnScJ/qCmIAMZkRyHH0vjHMMHmNM9T9 1VEg== X-Gm-Message-State: AOAM531DTyjVfG7NThLGCAxjRNPN1mfCB3zIr445sA/pap8eciSMp4n8 EDiy+A7R3UjEi+rO6EpauX+PAg== X-Google-Smtp-Source: ABdhPJwaiA5rH696JEVs1LyaPKo4rf9o9kfJpWWgIN+FdZR7N051iOYsTHra9i4SBRSPNHgi4Pjmnw== 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: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: CD68E801A8A0 X-Stat-Signature: 8xhg9nmp6i5hfbr9cghdu9cp91ye7we5 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Z6YEV8Co; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of seanjc@google.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=seanjc@google.com X-HE-Tag: 1634145888-720028 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: 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; + }