Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6915472rwd; Tue, 6 Jun 2023 04:00:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lWPLcK5i0fVSYpxE2rz/urIvhq2Rr7dvYTwnU2kkuV8iq4vMLy6E+hF/Xem/kDB3lh6Re X-Received: by 2002:a05:6214:765:b0:626:273e:c356 with SMTP id f5-20020a056214076500b00626273ec356mr1296747qvz.14.1686049240999; Tue, 06 Jun 2023 04:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686049240; cv=none; d=google.com; s=arc-20160816; b=Lm+BQa4VC+PNZUVVSt+Y51ErhLFdnFRdh7qIxY89BgltRNPAaU5nN9GppdSUsPwecy yd0MABc82joMDigMRg+hG60B9vblfi9CJJymwFd8G5Ium0pXqaNGtBGUv57OlL4JkVON 8ctdIFVOxXdQaGZD1S2Vl+s+Cj/DUA7oijotguMQkyLlwcI/FjOkWX3kjtiqEVC1MlTF TfeWSRfMtOryTyrbv8F6dgzxrEimXctvNXcNnFwU+OJQwJkY17ajCn3gwofKgzZ/WjB+ QDhn4qq1apVlIJMAfPCTV4V9NVEGKG3ccFF58K8iiscsR9vzkPh/2cwoMWC5fuujb7mv X5YA== 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=LKZHBTQJsCuoAoohz+zroXcxso0fO+DfPtF4FwQ6JrQ=; b=bejyZEO3qXyDIHUdisBeeK+0Sz5UBcibAvdrlfhHaxYOEpKndpjRPeapmG+rhGZAz8 Q0Bjw+4wrvSiFx4PG1/aEapWz7J3v/8gJSwVn+nNzgBCy45He+1RNMvXAV4UbzC0MDlX VY4zfQG2muPOJmp68Yqyk8sc9qpCTCU6/UhKf0jAcWnPFBV0eunaypzo8EuWBXNFUABU Pcimct/Ttqjdzz5BYaXqxn0pjEa6nkVLB1x4nM/aIf8MKWgQsSGPLjoeUer8Vb3ZQuwx Rc6T1bbkxS6B+Arq6r9ZrwF8u53DDon/3AEp91Br2Z6EIjiHx1tw+CXh/ovvm63qHBFH acpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@alien8.de header.s=dkim header.b=aj+IPK6W; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p19-20020a05622a049300b003e4ce105af5si6059614qtx.534.2023.06.06.04.00.25; Tue, 06 Jun 2023 04:00:40 -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=temperror (no key for signature) header.i=@alien8.de header.s=dkim header.b=aj+IPK6W; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236167AbjFFKtJ (ORCPT + 99 others); Tue, 6 Jun 2023 06:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233068AbjFFKrq (ORCPT ); Tue, 6 Jun 2023 06:47:46 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C89F0170C for ; Tue, 6 Jun 2023 03:46:45 -0700 (PDT) Received: from zn.tnic (pd9530d32.dip0.t-ipconnect.de [217.83.13.50]) (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 355EB1EC0506; Tue, 6 Jun 2023 12:46:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1686048404; 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=LKZHBTQJsCuoAoohz+zroXcxso0fO+DfPtF4FwQ6JrQ=; b=aj+IPK6W+uTJSsj9SzOf9R5uJqxArbY4N4/H6VACktKdkAE0fVh+Y3EfNAjgcCMzRQKgTl QIBEOsXDuvyZqB7eSb0iTBBOefZYyN4Z9wiSRIpVsO2y5iz45TTQwEDw3tUE4YemH0Y3l5 m/yYpiM2T5lcS8W4QdOsMo998wuEWRQ= Date: Tue, 6 Jun 2023 12:46:39 +0200 From: Borislav Petkov To: Tom Lendacky Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Dave Hansen , "Kirill A. Shutemov" , "H. Peter Anvin" , Michael Roth , Joerg Roedel , Dionna Glaze , Andy Lutomirski , Peter Zijlstra Subject: Re: [RESEND PATCH v8 4/6] x86/sev: Use large PSC requests if applicable Message-ID: <20230606104639.GMZH8Oj+84CvdXzAIW@fat_crate.local> References: <20230518231434.26080-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_NONE,SPF_PASS,T_FILL_THIS_FORM_SHORT, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 On Fri, May 19, 2023 at 11:30:11AM -0500, Tom Lendacky wrote: > diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c > index 973756c89dac..8802a75e1c20 100644 > --- a/arch/x86/kernel/sev.c > +++ b/arch/x86/kernel/sev.c > @@ -657,32 +657,58 @@ static u64 __init get_jump_table_addr(void) > return ret; > } > > -static void pvalidate_pages(unsigned long vaddr, unsigned long npages, bool validate) > +static void pvalidate_pages(struct snp_psc_desc *desc) > { > - unsigned long vaddr_end; > + struct psc_entry *e; > + unsigned long vaddr; > + unsigned int size; > + unsigned int i; > + bool validate; > int rc; > > - vaddr = vaddr & PAGE_MASK; > - vaddr_end = vaddr + (npages << PAGE_SHIFT); > + for (i = 0; i <= desc->hdr.end_entry; i++) { > + e = &desc->entries[i]; > + > + vaddr = (unsigned long)pfn_to_kaddr(e->gfn); > + size = e->pagesize ? RMP_PG_SIZE_2M : RMP_PG_SIZE_4K; > + validate = (e->operation == SNP_PAGE_STATE_PRIVATE) ? true : false; validate = e->operation == SNP_PAGE_STATE_PRIVATE; is enough :) -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette