From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 687EBC77B7A for ; Thu, 1 Jun 2023 21:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbjFAVt6 (ORCPT ); Thu, 1 Jun 2023 17:49:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233168AbjFAVtS (ORCPT ); Thu, 1 Jun 2023 17:49:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A522A19A for ; Thu, 1 Jun 2023 14:48:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E2DC464A45 for ; Thu, 1 Jun 2023 21:48:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FB64C433D2; Thu, 1 Jun 2023 21:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1685656133; bh=esZFBSLD6mtv8gZKB+SzLhtrGQU5qTEXtjt2SiuDsHg=; h=Date:To:From:Subject:From; b=wYZIvR0rAqo3NA1kRhfboD1inSdUETHq866kROp0C24kqMXY1ItmZbtV1Wyc2PuCh oTMIXmPIGesgda5eaYCYGbeZWMRPFyB8JmSGnxmO8jsGXGi2QSNrRibLFY/1ux0t4Z r9Xxxo/wGLJSn94T/EkHOt5lIrfN7LZC8EmT+ic8= Date: Thu, 01 Jun 2023 14:48:52 -0700 To: mm-commits@vger.kernel.org, vbabka@suse.cz, tim.gardner@canonical.com, thomas.lendacky@amd.com, tglx@linutronix.de, seanjc@google.com, sathyanarayanan.kuppuswamy@linux.intel.com, rppt@linux.ibm.com, rientjes@google.com, peterz@infradead.org, peterx@redhat.com, pbonzini@redhat.com, mingo@redhat.com, mgorman@techsingularity.net, marcelo.cerri@canonical.com, luto@kernel.org, liam.merwick@oracle.com, jroedel@suse.de, dfaggioli@suse.com, david@redhat.com, dave.hansen@linux.intel.com, dave.hansen@intel.com, bp@suse.de, bp@alien8.de, ardb@kernel.org, ak@linux.intel.com, aarcange@redhat.com, kirill.shutemov@linux.intel.com, akpm@linux-foundation.org From: Andrew Morton Subject: + x86-tdx-refactor-try_accept_one.patch added to mm-unstable branch Message-Id: <20230601214853.3FB64C433D2@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: x86/tdx: refactor try_accept_one() has been added to the -mm mm-unstable branch. Its filename is x86-tdx-refactor-try_accept_one.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/x86-tdx-refactor-try_accept_one.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: "Kirill A. Shutemov" Subject: x86/tdx: refactor try_accept_one() Date: Thu, 1 Jun 2023 21:25:42 +0300 Rework try_accept_one() to return accepted size instead of modifying 'start' inside the helper. It makes 'start' in-only argument and streamlines code on the caller side. Link: https://lkml.kernel.org/r/20230601182543.19036-9-kirill.shutemov@linux.intel.com Signed-off-by: Kirill A. Shutemov Suggested-by: Borislav Petkov Reviewed-by: Dave Hansen Cc: Andi Kleen Cc: Andrea Arcangeli Cc: Andy Lutomirski Cc: Ard Biesheuvel Cc: Borislav Petkov Cc: Dario Faggioli Cc: Dave Hansen Cc: David Hildenbrand Cc: David Rientjes Cc: Ingo Molnar Cc: Joerg Roedel Cc: Kuppuswamy Sathyanarayanan Cc: Liam Merwick Cc: Marcelo Henrique Cerri Cc: Mel Gorman Cc: Mike Rapoport Cc: Paolo Bonzini Cc: Peter Xu Cc: Peter Zijlstra Cc: Sean Christopherson Cc: Thomas Gleixner Cc: Tim Gardner Cc: Tom Lendacky Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- arch/x86/coco/tdx/tdx.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) --- a/arch/x86/coco/tdx/tdx.c~x86-tdx-refactor-try_accept_one +++ a/arch/x86/coco/tdx/tdx.c @@ -713,18 +713,18 @@ static bool tdx_cache_flush_required(voi return true; } -static bool try_accept_one(phys_addr_t *start, unsigned long len, - enum pg_level pg_level) +static unsigned long try_accept_one(phys_addr_t start, unsigned long len, + enum pg_level pg_level) { unsigned long accept_size = page_level_size(pg_level); u64 tdcall_rcx; u8 page_size; - if (!IS_ALIGNED(*start, accept_size)) - return false; + if (!IS_ALIGNED(start, accept_size)) + return 0; if (len < accept_size) - return false; + return 0; /* * Pass the page physical address to the TDX module to accept the @@ -743,15 +743,14 @@ static bool try_accept_one(phys_addr_t * page_size = 2; break; default: - return false; + return 0; } - tdcall_rcx = *start | page_size; + tdcall_rcx = start | page_size; if (__tdx_module_call(TDX_ACCEPT_PAGE, tdcall_rcx, 0, 0, 0, NULL)) - return false; + return 0; - *start += accept_size; - return true; + return accept_size; } /* @@ -788,21 +787,22 @@ static bool tdx_enc_status_changed(unsig */ while (start < end) { unsigned long len = end - start; + unsigned long accept_size; /* * Try larger accepts first. It gives chance to VMM to keep - * 1G/2M SEPT entries where possible and speeds up process by - * cutting number of hypercalls (if successful). + * 1G/2M Secure EPT entries where possible and speeds up + * process by cutting number of hypercalls (if successful). */ - if (try_accept_one(&start, len, PG_LEVEL_1G)) - continue; - - if (try_accept_one(&start, len, PG_LEVEL_2M)) - continue; - - if (!try_accept_one(&start, len, PG_LEVEL_4K)) + accept_size = try_accept_one(start, len, PG_LEVEL_1G); + if (!accept_size) + accept_size = try_accept_one(start, len, PG_LEVEL_2M); + if (!accept_size) + accept_size = try_accept_one(start, len, PG_LEVEL_4K); + if (!accept_size) return false; + start += accept_size; } return true; _ Patches currently in -mm which might be from kirill.shutemov@linux.intel.com are mm-add-support-for-unaccepted-memory.patch efi-x86-get-full-memory-map-in-allocate_e820.patch efi-libstub-implement-support-for-unaccepted-memory.patch x86-boot-compressed-handle-unaccepted-memory.patch efi-add-unaccepted-memory-support.patch efi-unaccepted-avoid-load_unaligned_zeropad-stepping-into-unaccepted-memory.patch x86-tdx-make-_tdx_hypercall-and-__tdx_module_call-available-in-boot-stub.patch x86-tdx-refactor-try_accept_one.patch x86-tdx-add-unaccepted-memory-support.patch