Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2954821rwa; Mon, 22 Aug 2022 17:47:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ALNDz5ScMNbucCMXWVFo/Ab08YYbKv/dnzcegEMvZ9kQBNBAxAmaX6Ey9KKJLwBcIqjyU X-Received: by 2002:a17:90b:2c42:b0:1fa:c295:3547 with SMTP id rw2-20020a17090b2c4200b001fac2953547mr873037pjb.236.1661215628724; Mon, 22 Aug 2022 17:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661215628; cv=none; d=google.com; s=arc-20160816; b=NmLjTg+9X4YbKUC0A6qb30ifdmYaBS6F1M0wARFaBHfHpX4aW1J5HKzbIUYgzc9wQ+ Ca3tlfKpvnm4ybkjku6ZEj3ulrSzrGbxyBIBGcLAlrr4qItX7VVLiqCwpiX8VuhiH1oM 4PI67C/RJgTZtSBCpsVlfo2bTSRIr1hqCEzOH3KdFQadiWsoOEscREpVg6imzAxe/Jxw PF7OSWgbiTMcfwJszPUBVrbT+gkLRnDhYoee9BHsRCqZEEFbcHq0GSIqnFOHv9uoH2LI Utwk5Gfo7t47ZGiv52c1bMj8XDac3lbqShX9QxgPh+ZCpTMMOioroTIqwmggjtZGj0RR qB4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6+1zWJmH8QXj8X4FXqMGXd6ZgOyPA1Adef25hUn+KAU=; b=s6JdqTkr1aToig/CRMEOZ8VGroCjJ7vvyV+HhufrQ51OD1XrsHWAP+ghMgC+Tz+QxE tOh3dbL0FiGX/SECw3aJpTtjN8rnwZQQew9kJiiLZbcsDBk2SFgblM5UJBwVPrT/9fTD gs/2NRiqsxIz4eimsCBXBfmNeHKjnm2aDDEpkcRXHAYZj5GtKU/LfRrs792ZCXYHxRB2 UAX4cxGOpNrpxBBBdtFp+q8pr+xin1/xSoQZsrKn8hjohmNsX7rbEkNYusaByZB27esT uYKt9Z1tpjeG6+phf1H4VhKn7gWll3iqhj1r0MyLojo8d2M1U4k6+dCujwzkSTTRblmd xjQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="PWiv/pt0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id je2-20020a170903264200b0016cc0e4c7d1si12920165plb.43.2022.08.22.17.46.58; Mon, 22 Aug 2022 17:47:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="PWiv/pt0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S239079AbiHWAYo (ORCPT + 99 others); Mon, 22 Aug 2022 20:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237871AbiHWAYm (ORCPT ); Mon, 22 Aug 2022 20:24:42 -0400 Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76EBF3DF1A for ; Mon, 22 Aug 2022 17:24:36 -0700 (PDT) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-3378303138bso298948557b3.9 for ; Mon, 22 Aug 2022 17:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=6+1zWJmH8QXj8X4FXqMGXd6ZgOyPA1Adef25hUn+KAU=; b=PWiv/pt0eSkF0f8mONhhv3hdl89iPmgPtUC9QM8RGL1OWPKWRZ9wY0lMUjFTEUMKsc 3hM5t30SApCzUy1DygscsE6x4XTmaiZlcEChFHEzbWyVLKdxNuA0HivzYEWnIaveOxS8 WEnphSUR3k+YjfElipFI3Yttz7grHqKyX6Yay4WoEwNpeicYVWtNkvVrIjF/ckciDzAM YBQjrMSrBtQcEsc9P9jW2lVqPXyLKT0sNFcXB3wIbvizqxm1xU8rTANVDZ0PKLsL+W5S NmIdB+O3irgvNYyWgb5v0ggWJHpOfCuI5Xg2QLVo327IF3nUVJO8p28HohVdXD8W6AGe ik0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=6+1zWJmH8QXj8X4FXqMGXd6ZgOyPA1Adef25hUn+KAU=; b=X/fYd0Qlgk3DSC28FB8Lt6ebVmGKNzW30q6SJiSHaqz8HMbABfPoZK3MEug2zooIGk CBOR+w09zOqKjIbrU+mKnL5NCoY+Qv8+WgBgMoEW37BkLtBpwMXG+l7QSUwC1RTDyoGZ 1lCLm/8lZZmLaMr2ZkjgPaIvfMeBXEv7db+QZHJ33j1+tpDpZJQPoZKM2PSxdW2ODl+u 81JNpxJ0Lar+ldufuBHlw4uI8PKwb/7GxwLwKTnbG5xjtAQ+DVNOo8mKXe0cUh/7PNd4 LvqUKW8WXRBzkD+coswNCQLctWL09oTSs3PMoA37+MNjAVWtJ25qmPqSyxbiXCgo870f eTGw== X-Gm-Message-State: ACgBeo0NAWZYeHo0Yyd1YUX6jugnp0fIvIiaeisSfl3d2GiW5Yhj8HtM WqHvF04l5T2nlnoVdCaikreOIdxXdHvo9sE3KklgoA== X-Received: by 2002:a25:40c5:0:b0:694:e710:a26 with SMTP id n188-20020a2540c5000000b00694e7100a26mr17417813yba.509.1661214275620; Mon, 22 Aug 2022 17:24:35 -0700 (PDT) MIME-Version: 1.0 References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <44495aa8acb666b447a08a1c3af80987aa3cea3a.1659103274.git.thomas.lendacky@amd.com> In-Reply-To: <44495aa8acb666b447a08a1c3af80987aa3cea3a.1659103274.git.thomas.lendacky@amd.com> From: Dionna Amalie Glaze Date: Mon, 22 Aug 2022 17:24:24 -0700 Message-ID: Subject: Re: [PATCH v1 2/2] x86/sev: Add SNP-specific unaccepted memory support To: Tom Lendacky Cc: LKML , "the arch/x86 maintainers" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "Kirill A. Shutemov" , "H. Peter Anvin" , Michael Roth , Joerg Roedel , Andy Lutomirski , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_FILL_THIS_FORM_SHORT,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > +void snp_accept_memory(phys_addr_t start, phys_addr_t end) > +{ > + unsigned long vaddr; > + unsigned int npages; > + > + if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) > + return; > + > + vaddr = (unsigned long)__va(start); > + npages = (end - start) >> PAGE_SHIFT; > + > + set_pages_state(vaddr, npages, SNP_PAGE_STATE_PRIVATE); > + > + pvalidate_pages(vaddr, npages, true); > +} My testing of this patch shows that a significant amount of time is spent using the MSR protocol to change page state, in such a significant fashion that it's slower than eagerly accepting all memory. The difference gets worse as the RAM size goes up, so I think there's some phase problem with the GHCB protocol not getting used early enough? -- -Dionna Glaze, PhD (she/her)