Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1232449pxj; Fri, 21 May 2021 09:17:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKlsVWwnfrVZxOf6DkzMqJvQBJjqS1ZeQ1xHK6ppR9poEsvVQ4DjTrSjxcD6+Wk2mAs2vP X-Received: by 2002:a50:a446:: with SMTP id v6mr12197038edb.254.1621613837516; Fri, 21 May 2021 09:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621613837; cv=none; d=google.com; s=arc-20160816; b=a4T0tWUe/zAhapO+qgXBJKzF791VmtQX1aPWSE5HNpVbrgsvlK1U2yE87Oc158az3D bsPk8jhJCnw5wMqCA1A7Vs9YJqTifaY+f4mDeGKFnW5U2pD4Y7xqDLEV4SpkTd1kRhYY UoXxlkAYkKTe+IuytYHWDq/nfTYHPATaJokSJXKDo+yTy4owqNpgpGCOvwhFW79Wj6Ns 8YCyd3QDPy0nySxrOcLfjhWOqFvUJ/Pj6+/SMT44iqrakcK3G4djRZ2z32UWeLkQ7dn8 zqeVFn8gbGeSon1MzDQhQRFrS+Hs8auuyH9u/brL0ldFqZmFX/MLmjdtKjFaysdSqOZD mEaQ== 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=fqWT78r8absILqyZ0+NWjNXYlWzdX8hYWzydvSsw51g=; b=ycYHQdWiH+b0cLLQg5jt2+vW6ipaQSnKZhPvFj2E/OkFZKMQXvwswVCW/p4H7i8GWG v8ePeHt+Jt813fZQiEnjERrhhPNMsVSU73JcvM6PXC2ISAD83dr2ctyaUmkZvl9Hvsb3 zGL8KrgTepf63cLhIrmDqz7h6P0VLun6sP/R93yHaDnXEapcvoU7hB85O+8MtdumuPFd g1b5vrry1sX8CTpQitLkZDcubh9bd3TM/h+RbvBM/OXajXtiIjOCj9hYHnInOz9FwKxP ThnF+/PhD8GgoZ6u/funWzkELEOaF2N53j4IjTKVi0QpvAX45M+qf4exJJdC/N5rSFQq AvdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="XlHOrw/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs19si5707807ejb.238.2021.05.21.09.16.53; Fri, 21 May 2021 09:17:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@alien8.de header.s=dkim header.b="XlHOrw/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235856AbhETRyB (ORCPT + 99 others); Thu, 20 May 2021 13:54:01 -0400 Received: from mail.skyhub.de ([5.9.137.197]:44986 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235791AbhETRyA (ORCPT ); Thu, 20 May 2021 13:54:00 -0400 Received: from zn.tnic (p200300ec2f0eb6009f35b1f88a592069.dip0.t-ipconnect.de [IPv6:2003:ec:2f0e:b600:9f35:b1f8:8a59:2069]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id D15011EC064C; Thu, 20 May 2021 19:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1621533158; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=fqWT78r8absILqyZ0+NWjNXYlWzdX8hYWzydvSsw51g=; b=XlHOrw/WI7akbnhiyT8ZYKHdIbaI3O3Yds2i8qBfAT3wDosVPmpYUQbZbdzRn8czd8W3TP OBQ24YAw6tqAmQmFsJ+fFcq9cRyg36HZefJnTJL57moEg/FKHTNu1ipS3N8uhdDPsHxPFb n3zCbb991H1GdGH6QB90QLX+ahwXkjk= Date: Thu, 20 May 2021 19:52:37 +0200 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, tglx@linutronix.de, jroedel@suse.de, thomas.lendacky@amd.com, pbonzini@redhat.com, mingo@redhat.com, dave.hansen@intel.com, rientjes@google.com, seanjc@google.com, peterz@infradead.org, hpa@zytor.com, tony.luck@intel.com Subject: Re: [PATCH Part1 RFC v2 11/20] x86/compressed: Add helper for validating pages in the decompression stage Message-ID: References: <20210430121616.2295-1-brijesh.singh@amd.com> <20210430121616.2295-12-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210430121616.2295-12-brijesh.singh@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 30, 2021 at 07:16:07AM -0500, Brijesh Singh wrote: > @@ -278,12 +279,28 @@ static int set_clr_page_flags(struct x86_mapping_info *info, > if ((set | clr) & _PAGE_ENC) > clflush_page(address); > > + /* > + * If the encryption attribute is being cleared, then change the page state to > + * shared in the RMP entry. Change of the page state must be done before the > + * PTE updates. > + */ > + if (clr & _PAGE_ENC) > + snp_set_page_shared(pte_pfn(*ptep) << PAGE_SHIFT); From the last review: The statement above already looks at clr - just merge the two together. > @@ -136,6 +137,55 @@ static inline bool sev_snp_enabled(void) > return sev_status_val & MSR_AMD64_SEV_SNP_ENABLED ? true : false; > } > > +static void snp_page_state_change(unsigned long paddr, int op) From the last review: no need for too many prefixes on static functions - just call this one __change_page_state() or so, so that the below one can be called... > +{ > + u64 val; > + > + if (!sev_snp_enabled()) > + return; > + > + /* > + * If the page is getting changed from private to shard then invalidate the page shared And you can write this a lot shorter * If private -> shared, ... > + * before requesting the state change in the RMP table. > + */ > + if ((op == SNP_PAGE_STATE_SHARED) && pvalidate(paddr, RMP_PG_SIZE_4K, 0)) > + goto e_pvalidate; > + > + /* Issue VMGEXIT to change the page state in RMP table. */ > + sev_es_wr_ghcb_msr(GHCB_MSR_PSC_REQ_GFN(paddr >> PAGE_SHIFT, op)); > + VMGEXIT(); > + > + /* Read the response of the VMGEXIT. */ > + val = sev_es_rd_ghcb_msr(); > + if ((GHCB_RESP_CODE(val) != GHCB_MSR_PSC_RESP) || GHCB_MSR_PSC_RESP_VAL(val)) > + goto e_psc; That label is used only once - just do the termination here directly and remove it. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette