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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AF77C4338F for ; Tue, 10 Aug 2021 06:26:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 85FF26108F for ; Tue, 10 Aug 2021 06:26:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 85FF26108F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id B164A6B0071; Tue, 10 Aug 2021 02:26:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC6086B0072; Tue, 10 Aug 2021 02:26:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B4826B0073; Tue, 10 Aug 2021 02:26:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id 7ECF66B0071 for ; Tue, 10 Aug 2021 02:26:26 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6D3311F858 for ; Tue, 10 Aug 2021 06:26:25 +0000 (UTC) X-FDA: 78458186730.28.939CF56 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf10.hostedemail.com (Postfix) with ESMTP id 2C7E760022F0 for ; Tue, 10 Aug 2021 06:26:25 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id y34so9288810lfa.8 for ; Mon, 09 Aug 2021 23:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KJblD1y+qHn3wdjDCoDkUfQxp7E9z/k1WwnfUwfIYyM=; b=WYP8kUAPCPad7gI6jY98V65Vgu7u4/0nE4cFaF3MnWAhh+uO5OikXIunOk5RNWWCkS 2L6VtL9haY/GqvhguHP/OSS0aEwBYpZBbwTv59KTSkIWXCAubBcnZv+Ls75+kPb7Hwdr QFsD1CY6vuPvVsb34IIukZYV4wBtB8OTcY89cNj4qUQjXOv3Cr67D/BbNJNOcCdgw3jI vUDVtu1E7ioVS7PDsYvp93akWuyAEw01sq0vGI5iAfR3lnitOOFNtmVwHjugdjbv8j2t VqvUd/LaVckZJjeD2gl4nlS9FnV1DW56dAPD5t5rtIGQEDH4QrcqceouPgW1n3XS3B/+ ouPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KJblD1y+qHn3wdjDCoDkUfQxp7E9z/k1WwnfUwfIYyM=; b=Hbbe6LYrEVED9wrhcX0rGXlp4FBt0o0qJUPNWp87UUmWdSZ/uTO02fGzIcBvgQQygl omiECiW5qkqD0ogqYZN13JIQRx8QMMPTLF3MobmW6yge92RASjRwxByrNalgn+pnelwi 5KxpIVKywX3Q6/XyaG8BAAbeyckP0+HczIFb/QKV1/odaHL9CFIcdRZ2DLjC87TjVISZ RWBngacMiZO7xNtcA7+zeLCvHgChidh1NI9IS/3kSIt8Zx40HNHyQQFHD/COuQK8CKUR IjPC3NsyfpLSQQC2wn/cGF3cUEs0QXc4L3U0QElIDK6YL95ahyltvvoVxL8f1NmDNvia SUFA== X-Gm-Message-State: AOAM530DSMFlHRYY1sf4W2Q2sOH58kLw92+AXr+PBQS0xdHk0ui545mU 5ZCl6Arkdt0PSFqvCUUPGPiUJA== X-Google-Smtp-Source: ABdhPJwEfhyq1oDAPUD+NUvsniIszXrUrcqLIpaj8cWNmXevuFhB6Zr+WNuDP199OnFXqedrudhx9A== X-Received: by 2002:ac2:4472:: with SMTP id y18mr20677419lfl.137.1628576783588; Mon, 09 Aug 2021 23:26:23 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id c9sm1957788lfr.46.2021.08.09.23.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 23:26:22 -0700 (PDT) From: "Kirill A. Shutemov" X-Google-Original-From: "Kirill A. Shutemov" Received: by box.localdomain (Postfix, from userid 1000) id 8BED5102BBF; Tue, 10 Aug 2021 09:26:34 +0300 (+03) To: Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel Cc: Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 0/5] x86: Impplement support for unaccepted memory Date: Tue, 10 Aug 2021 09:26:21 +0300 Message-Id: <20210810062626.1012-1-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=WYP8kUAP; dmarc=none; spf=none (imf10.hostedemail.com: domain of kirill@shutemov.name has no SPF policy when checking 209.85.167.49) smtp.mailfrom=kirill@shutemov.name X-Stat-Signature: w1uq8kbbesk7gskhpqfn5txb1gwbpynb X-Rspamd-Queue-Id: 2C7E760022F0 X-Rspamd-Server: rspam01 X-HE-Tag: 1628576785-954562 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: UEFI Specification version 2.9 introduces concept of memory acceptance: Some Virtual Machine platforms, such as Intel TDX or AMD SEV-SNP, requiring memory to be accepted before it can be used by the guest. Accepting happens via a protocol specific for the Virtrual Machine platform. Accepting memory is costly and it makes VMM allocate memory for the accepted guest physical address range. We don't want to accept all memory upfront. The patchset implements on-demand memory acceptance for TDX. Please, review. Any feedback is welcome. Kirill A. Shutemov (5): mm: Add support for unaccepted memory efi/x86: Implement support for unaccepted memory x86/boot/compressed: Handle unaccepted memory x86/mm: Provide helpers for unaccepted memory x86/tdx: Unaccepted memory support Documentation/x86/zero-page.rst | 1 + arch/x86/Kconfig | 1 + arch/x86/boot/compressed/Makefile | 1 + arch/x86/boot/compressed/bitmap.c | 86 ++++++++++++++++++++ arch/x86/boot/compressed/kaslr.c | 14 +++- arch/x86/boot/compressed/misc.c | 9 ++ arch/x86/boot/compressed/tdx.c | 29 +++++++ arch/x86/boot/compressed/unaccepted_memory.c | 51 ++++++++++++ arch/x86/include/asm/page.h | 5 ++ arch/x86/include/asm/tdx.h | 2 + arch/x86/include/asm/unaccepted_memory.h | 17 ++++ arch/x86/include/uapi/asm/bootparam.h | 3 +- arch/x86/kernel/tdx.c | 8 ++ arch/x86/mm/Makefile | 2 + arch/x86/mm/unaccepted_memory.c | 84 +++++++++++++++++++ drivers/firmware/efi/Kconfig | 12 +++ drivers/firmware/efi/efi.c | 1 + drivers/firmware/efi/libstub/x86-stub.c | 75 ++++++++++++++--- include/linux/efi.h | 3 +- mm/internal.h | 14 ++++ mm/memblock.c | 1 + mm/page_alloc.c | 13 ++- 22 files changed, 414 insertions(+), 18 deletions(-) create mode 100644 arch/x86/boot/compressed/bitmap.c create mode 100644 arch/x86/boot/compressed/unaccepted_memory.c create mode 100644 arch/x86/include/asm/unaccepted_memory.h create mode 100644 arch/x86/mm/unaccepted_memory.c --=20 2.31.1