Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp610061pxv; Thu, 15 Jul 2021 11:26:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4UHiE4WQFwCKVbWrAUAFpGfrVfLlGIS1kADv6FSdV5NqmwM/hlufOT+nKYOsR2TKCT5/U X-Received: by 2002:a92:3004:: with SMTP id x4mr3573982ile.269.1626373619182; Thu, 15 Jul 2021 11:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626373619; cv=none; d=google.com; s=arc-20160816; b=YQ10Ef6MnSL64ciK2VsYcBN+lgLMYA21K9gD9QpjkyWDxtmqwiyJ6QgxURcPnR74LF kZ5Bkey56/Z7kgQG7BpOXWNw/jVsrK9n60GGYNFxQavU8S4/l5WZvrqKEj8mQiSb5Pqb b2dNl+4DKZ9M/ZsgoGzSqdU2BAxok8wJCFHH/J+iuUPiXax9uF1fIG84FmaFq7hdXnY9 SUcWAcr+eAwIXJX7qCiYuhVPcD/Qug9D/ATXPHsL+QOFTBUxspeBBy1Sy65AiUUkUI2o tefYMhjEzNWuV1Fl5XZRpGtvLHt3edUFzMbVYScRld/chGQLhPXLf45DlHVp0a93NtnE iYiw== 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=SPUir8j18PLybVHK4M3a0vCQIxEbnuUyBjChvlSKLmw=; b=Ba0B9dRn2wCPgNOyRECY5oDRJncdBorlJ/vqIjWeT/CfrqFHF5tFWSkMpkQ/y7YB+9 zYTTA16rln0BErx/UUTYgbKT9lxXPKP+dj8CUd8cZWTGrf5T0RSGkq/K9WxxswR5wYQW GyFEr0ab9CjlKE+8fmxkmU4bSyymsS2TFrBA1zsZ4OlQK2lxMCJM6tL8cRlK+Ztbyl+3 N0zWQs6LC9TGqHbiYMgN+DoZN9VWX2DDNin/Z+DuJryQKflAayodNt1B2rns4dnaguxo d+6uIetSoWJ51gTZsrD2nC0tiKYqNdKYY+ytnEXQSEwcn2ruxx/8WB685v2NVCdoAiGI tvHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=O6AX+9hz; 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 p29si6314356jal.22.2021.07.15.11.26.37; Thu, 15 Jul 2021 11:26:59 -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=20161025 header.b=O6AX+9hz; 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 S235437AbhGORy0 (ORCPT + 99 others); Thu, 15 Jul 2021 13:54:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230082AbhGORyZ (ORCPT ); Thu, 15 Jul 2021 13:54:25 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74621C061764 for ; Thu, 15 Jul 2021 10:51:32 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id v18-20020a17090ac912b0290173b9578f1cso6042760pjt.0 for ; Thu, 15 Jul 2021 10:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SPUir8j18PLybVHK4M3a0vCQIxEbnuUyBjChvlSKLmw=; b=O6AX+9hzZex3eU5uvfUHqD2gB8kkBZk+ho0pFS2dUIJw1QUWPEIQ3cGrzjEgmQ5EGx gYai+UQVtsPWNE6v8zHWdWbJJXlcF02q/r7/sQz/nFxk1BSaW85VYOSPU3ABhgUDkUur 5N6ceKHGHDX7KUttzFzG/IKO2ub60a5iylSdkeqcMkchE0JkEuAicdvSqID+aIUDAu1A Az9u0TdsmnrXPgK4u5zDJWgJfYtd4H1fQ8U39B5RZq1fYuA2RNah69hBucHHAQrhcpK6 H7NekraqO2ltqIVdk8+zE5/NUcItPe6ci/slDsqdql74v6bwnu6pit9OxnS4H2jQscpC Dt/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SPUir8j18PLybVHK4M3a0vCQIxEbnuUyBjChvlSKLmw=; b=kFhaailmu0PmTBZuTeRoYa/2L/JpHNE4z/1o/Ma9toVfs+8VwZQxjnnCWzFJ4/jaC1 Uijm7LRB6EGXeiSaqDgqjFAlfcGKCOTYXWXNaOGvHztXi38dxXBUg2emow8gDwmnI+EA TR0VX85TqHTmKJ/z7bQkp0vjaFxJFCoEWX7afqOvPJBuAhZ5TG4e2WYI/iYSIfAQmWRs OaPL04G7xkOS+Vx02s84g/5ahyLlBJM+a5XMFWH7COpah5IY5y2/zGFIv2x2WERUi/NC 0bja5gE37fCydXFCxhScW1SAWALhj+pQ9Jb15frkK9CZhEBaShw8zU3rZEPpirwTzR2n L1tQ== X-Gm-Message-State: AOAM532AsPUJeL8Bb+2wQUVVI2ZHLQQcc2H8HJDKb1kALWncM8UWAIwr sAqC5eSkc5ZN9mQKG5j9kFDy6w== X-Received: by 2002:a17:90a:9f06:: with SMTP id n6mr5466944pjp.92.1626371491663; Thu, 15 Jul 2021 10:51:31 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id j19sm8009841pgm.44.2021.07.15.10.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 10:51:31 -0700 (PDT) Date: Thu, 15 Jul 2021 17:51:27 +0000 From: Sean Christopherson To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@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 , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com Subject: Re: [PATCH Part2 RFC v4 07/40] x86/sev: Split the physmap when adding the page in RMP table Message-ID: References: <20210707183616.5620-1-brijesh.singh@amd.com> <20210707183616.5620-8-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 Thu, Jul 15, 2021, Brijesh Singh wrote: > > On 7/14/21 5:25 PM, Sean Christopherson wrote: > > > @@ -2375,6 +2375,12 @@ int rmpupdate(struct page *page, struct rmpupdate *val) > > > if (!cpu_feature_enabled(X86_FEATURE_SEV_SNP)) > > > return -ENXIO; > > > + ret = set_memory_4k((unsigned long)page_to_virt(page), 1); > > > > IIUC, this shatters the direct map for page that's assigned to an SNP guest, and > > the large pages are never recovered? > > > > I believe a better approach would be to do something similar to memfd_secret[*], > > which encountered a similar problem with the direct map. Instead of forcing the > > direct map to be forever 4k, unmap the direct map when making a page guest private, > > and restore the direct map when it's made shared (or freed). > > > > I thought memfd_secret had also solved the problem of restoring large pages in > > the direct map, but at a glance I can't tell if that's actually implemented > > anywhere. But, even if it's not currently implemented, I think it makes sense > > to mimic the memfd_secret approach so that both features can benefit if large > > page preservation/restoration is ever added. > > > > thanks for the memfd_secrets pointer. At the lowest level it shares the > same logic to split the physmap. We both end up calling to > change_page_attrs_set_clr() which split the page and updates the page > table attributes. > > Given this, I believe in future if the change_page_attrs_set_clr() is > enhanced to track the splitting of the pages and restore it later then it > should work transparently. But something actually needs to initiate the restore. If the RMPUDATE path just force 4k pages then there will never be a restore. And zapping the direct map for private pages is a good thing, e.g. prevents the kernel from reading garbage, which IIUC isn't enforced by the RMP?