Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3800876pxb; Wed, 13 Oct 2021 13:17:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCIM5vzifaHgRg2px7lgfxzjbPznXiPpkcqBAeETJnNjVXoGntCJqPe7NN/Rp+3MVn4G5I X-Received: by 2002:a17:906:5d5:: with SMTP id t21mr1681313ejt.160.1634156247154; Wed, 13 Oct 2021 13:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634156247; cv=none; d=google.com; s=arc-20160816; b=JzAjv2beBONXSEWuF1lIrah1WEnFRUvhmpLBxs0cSajlfC7YvSnbrpgO6YVrgJ4YfG d2RAJwg7FAfolW/So66rm+ungCK36bhJIPU8EH+Owy/waAISq0Om1IDGc9NPEjFlvrq3 72gCSUTMoP2ZhWcw5Zf2zZm8Sgb/lhiKOpUd2fnhRbKcPPTKOHqrZ+FD0PaqlcKjfVfO 2HgQyNbmoDZ4whrS4kh/NWadfFZwc6Vha+jYcSndt/c5KSe2BjOy+6IaPw/2vwKruJiJ mlz2YSMk/7OzX4R62xDl3wyhsJ02duM6x6t+k54l+OcZqDKy3cAugfdYUu9tjnpQPq2A xsbQ== 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=5yhRH7ZIJi4Rd6WTmMMqH8HhEZQLNXc5e/9FRtAhMOI=; b=J3QkILMtOX4lu7/HkUO128d72ZUHP1aW+IgJoRgXLS5c5hRWoW0hI2Lzo2qt21hk8I t815dhvoHoxTjolEHDVp1pUJf94qe/LPDxUr/V99E+lKGPQS/yGoTGCCT0jcG3t4v81G sAKbGZsGAiy6sHe8E8DUPnG0/vcq5rd2R3ID4BoaIiVh50jasP4j04XcMG6A0v5q8BBX HdDgkvG5qVNmYSGHiMl2acz5DB2w+rpnQpS1LhPRFws/RGMP+9XvFHzg+sds+JuYMFD5 gxNP9cb3cKry82uECMdWxNXNwc49yw+Xy9DU4dt3yKZIP7/oukVwWsm+aNbM+TVWPlzB D88Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RPhDaWnp; 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 d22si663069edj.390.2021.10.13.13.17.00; Wed, 13 Oct 2021 13:17:27 -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=RPhDaWnp; 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 S229721AbhJMUS6 (ORCPT + 99 others); Wed, 13 Oct 2021 16:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbhJMUS5 (ORCPT ); Wed, 13 Oct 2021 16:18:57 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63F8DC061746 for ; Wed, 13 Oct 2021 13:16:54 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id x130so3473942pfd.6 for ; Wed, 13 Oct 2021 13:16:54 -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=5yhRH7ZIJi4Rd6WTmMMqH8HhEZQLNXc5e/9FRtAhMOI=; b=RPhDaWnpurS4y7tVtRZqV2m7TT/CvyExa80zu6eKOfi+Uxq6OHkuPWKuzBu6usovry 1r5rS6U2o3QdPYKrrldUS3PG46VJM5XJ2jtd33eGezktpZLITFB62sVzB1xF+QWmQaYs 4lw6stQbe55qE7qBX+H95iI+3MJ7iWrKq5aThQoS+CDOFbq9aHteipRRBoAwV4uM/anD EZ86zFuK/mnrh84e5NkEyIliobHoUE58WGdSy5se484Rd0wh2bLKfWmvsE6lHQ/99GMd jfvaDnPWztORPtxmDG6KJGEGfMa2WvnYpQvEZrq/5p6G0eQupghkiidJ69V+q6DshQJJ eHpQ== 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=5yhRH7ZIJi4Rd6WTmMMqH8HhEZQLNXc5e/9FRtAhMOI=; b=sjbOskq7os6b2idJcFdZoQJi8YTa2O0tG216ld+4TRm1vPB1Ugo0NCHCw+AaXqjVoN e040RhvPDvuPFcdE4zk7AwBodUGrhuKKSGk62yAWUglWrWh2vzBdOuFKmcq70wSIc42w SHOXROiszPCLQ35gftJ1cDeRM4DByaPLLy1tPNmcIlpNyH5WwV552WmQMKptToiWQrsU c3fiPgnBLRVR/+6r7W7J7ykI0GzYiuTmde+aZeqWt/td9iFcMarTTTaX64/uOwTapNg0 LbvkDNTMWYD6P5sQ5c6Pok18xYs+XsevOU8QsnFEDzRYrbM9FfDDwYkEXdBV3DGMI3gA M/Fg== X-Gm-Message-State: AOAM532UiZUjuHcrxI4WNOwwjUmCnb4YZaaqwa7Z6CVMEVLTXh8XY+Fo /UB9nSBWGZZX62woqYB+B5delg== X-Received: by 2002:a63:7c5b:: with SMTP id l27mr393227pgn.227.1634156213632; Wed, 13 Oct 2021 13:16:53 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id y3sm334520pjg.7.2021.10.13.13.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 13:16:53 -0700 (PDT) Date: Wed, 13 Oct 2021 20:16:49 +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 39/45] KVM: SVM: Introduce ops for the post gfn map and unmap Message-ID: References: <20210820155918.7518-1-brijesh.singh@amd.com> <20210820155918.7518-40-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, Sean Christopherson wrote: > On Fri, Aug 20, 2021, Brijesh Singh wrote: > > When SEV-SNP is enabled in the guest VM, the guest memory pages can > > either be a private or shared. A write from the hypervisor goes through > > the RMP checks. If hardware sees that hypervisor is attempting to write > > to a guest private page, then it triggers an RMP violation #PF. > > > > To avoid the RMP violation, add post_{map,unmap}_gfn() ops that can be > > used to verify that its safe to map a given guest page. Use the SRCU to > > protect against the page state change for existing mapped pages. > > SRCU isn't protecting anything. The synchronize_srcu_expedited() in the PSC code > forces it to wait for existing maps to go away, but it doesn't prevent new maps > from being created while the actual RMP updates are in-flight. Most telling is > that the RMP updates happen _after_ the synchronize_srcu_expedited() call. Argh, another goof on my part. Rereading prior feedback, I see that I loosely suggested SRCU as a possible solution. That was a bad, bad suggestion. I think (hope) I made it offhand without really thinking it through. SRCU can't work in this case, because the whole premise of Read-Copy-Update is that there can be multiple copies of the data. That simply can't be true for the RMP as hardware operates on a single table. In the future, please don't hesitate to push back on and/or question suggestions, especially those that are made without concrete examples, i.e. are likely off the cuff. My goal isn't to set you up for failure :-/