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 44150C433EF for ; Mon, 15 Nov 2021 18:26:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C1940634E8 for ; Mon, 15 Nov 2021 18:26:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C1940634E8 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 3ED5B6B0078; Mon, 15 Nov 2021 13:26:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 376C26B007B; Mon, 15 Nov 2021 13:26:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EF946B007E; Mon, 15 Nov 2021 13:26:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 0BEAD6B0078 for ; Mon, 15 Nov 2021 13:26:23 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C49DA82D9F for ; Mon, 15 Nov 2021 18:26:22 +0000 (UTC) X-FDA: 78811994604.16.D51E339 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf30.hostedemail.com (Postfix) with ESMTP id AF56BE0019B4 for ; Mon, 15 Nov 2021 18:25:57 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id p18-20020a17090ad31200b001a78bb52876so13728869pju.3 for ; Mon, 15 Nov 2021 10:26:22 -0800 (PST) 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=A9PRl8Edo1EWLltgYNzeLAxhIeguWSTUtvI4vu4lOU0=; b=Tv74eWk0THvgIgB6wM77S6Ef1ZXOnEycR/P0bJH/PHV0rI8Xd2WKU7UgRcZBcU1J8d 70izO3lKwvwLV5d9KsCpEb9gYKTwFplQAH6SMcE6qi4Sg7F51ov9sSSkn1nleOTVRI90 VBYOU7WTqSm8olxqB+csjjUk5YmghZ9mYNkd/tXqfSW59kxs7JF/DhYXHbWwxrNgIfju uoCo2v6lkkLeMTRBUnW0ULL6rMDoNAN2wEteSyBra/V5CM2tI5Aix9i5EIhfjzmOLFwM 7QS9XB6Wghv45R/RHrO+ZRrVtMQuAZmrizaTWExRWL8igX4GF0a++ljsaMY2CGtqT8ar xn8w== 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=A9PRl8Edo1EWLltgYNzeLAxhIeguWSTUtvI4vu4lOU0=; b=c4msdpwq1Q5Em+wBvxBl7lyE+8HGtN5FAuz5OkpH8+mBk/AiSad3bSEKQk8sFl6bn0 f+WQ660tMJQT5m4J6wjw9LurVmgCSk8mL7dnUvoZMgF+bhSg4JAnKp4J59UWPd2m3fpA jVBSeinq5S59iXUl1rcAzafTnfu5oVuvhsyqZZcQXciecrJpvrPCHeMf1EYbaFR06qj7 MnHmRl7bK1b6mm4zkAQDR9qeABhLLSspQPzhjMAPJTTROPDVo4zFbrFaOhxmUqe23JQE 3ixjse4ez2KAxiSdKk5VD/EJYG2U1Gf+6jXQwk1FaNqbvNdgZ0lVSMO4JbleJDuy4qv9 9oBA== X-Gm-Message-State: AOAM533uQY5bhHuoGQv59sOt68msC3dH9zNbJl7fQnKst3hgWgvrMVzp EmVqiVSFqmUrORUvBYHvfCvP/g== X-Google-Smtp-Source: ABdhPJzK5CjhfcvH0PmOfpiEEoynXyH6jQCHvXEWNSTTtJYReVaHOW8puWF5UMHDZMQhJJBwpkgApA== X-Received: by 2002:a17:903:2306:b0:142:123a:24ec with SMTP id d6-20020a170903230600b00142123a24ecmr37182268plh.21.1637000781046; Mon, 15 Nov 2021 10:26:21 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id ot7sm63595pjb.21.2021.11.15.10.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 10:26:20 -0800 (PST) Date: Mon, 15 Nov 2021 18:26:16 +0000 From: Sean Christopherson To: "Dr. David Alan Gilbert" Cc: Borislav Petkov , Dave Hansen , Peter Gonda , Brijesh Singh , 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 Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , 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 00/45] Add AMD Secure Nested Paging (SEV-SNP) Hypervisor Support Message-ID: References: <20210820155918.7518-1-brijesh.singh@amd.com> <061ccd49-3b9f-d603-bafd-61a067c3f6fa@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: AF56BE0019B4 X-Stat-Signature: pn1rat5yyy7jps9ygkigkjfug3k79kh7 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Tv74eWk0; spf=pass (imf30.hostedemail.com: domain of seanjc@google.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=seanjc@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1637000757-73810 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 Mon, Nov 15, 2021, Dr. David Alan Gilbert wrote: > * Sean Christopherson (seanjc@google.com) wrote: > > On Fri, Nov 12, 2021, Borislav Petkov wrote: > > > On Fri, Nov 12, 2021 at 09:59:46AM -0800, Dave Hansen wrote: > > > > Or, is there some mechanism that prevent guest-private memory from being > > > > accessed in random host kernel code? > > > > Or random host userspace code... > > > > > So I'm currently under the impression that random host->guest accesses > > > should not happen if not previously agreed upon by both. > > > > Key word "should". > > > > > Because, as explained on IRC, if host touches a private guest page, > > > whatever the host does to that page, the next time the guest runs, it'll > > > get a #VC where it will see that that page doesn't belong to it anymore > > > and then, out of paranoia, it will simply terminate to protect itself. > > > > > > So cloud providers should have an interest to prevent such random stray > > > accesses if they wanna have guests. :) > > > > Yes, but IMO inducing a fault in the guest because of _host_ bug is wrong. > > Would it necessarily have been a host bug? A guest telling the host a > bad GPA to DMA into would trigger this wouldn't it? No, because as Andy pointed out, host userspace must already guard against a bad GPA, i.e. this is just a variant of the guest telling the host to DMA to a GPA that is completely bogus. The shared vs. private behavior just means that when host userspace is doing a GPA=>HVA lookup, it needs to incorporate the "shared" state of the GPA. If the host goes and DMAs into the completely wrong HVA=>PFN, then that is a host bug; that the bug happened to be exploited by a buggy/malicious guest doesn't change the fact that the host messed up.