From patchwork Wed Apr 12 18:44:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gerst X-Patchwork-Id: 8087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp537470vqo; Wed, 12 Apr 2023 11:52:23 -0700 (PDT) X-Google-Smtp-Source: AKy350Ym4Dp9MbxOPjY5swFi+4jGS3a1mOrTReAuA/NsXD2L4aDoY6iHxQWJI0EqJwwgLDu3x6gM X-Received: by 2002:a17:903:294c:b0:1a5:167f:620f with SMTP id li12-20020a170903294c00b001a5167f620fmr6714848plb.15.1681325543540; Wed, 12 Apr 2023 11:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681325543; cv=none; d=google.com; s=arc-20160816; b=LVIzWXpGphe+moD+SWXrdy3/WLNNAu74qhAvaBlJvpZnCluLlMduJrDtRvo+bH6bU0 Ye5NAK+hvzG55AAAjE2SSTtUsUN+3slaqZCd8eniXEG0CQMRzfy5qH8zCe88H6L1Hd9R Zp+V696lv39GJCettdZ4Vd7eqAds2E4cOE0DSuU4GuiuzWbGbSYOq17mYA6FPgZxt78/ NIQlZO+fdjNIvZ2RqJXMTdewNTVck0kUgS5nxiUWnzvswfiEWjyhOGn2sKhUzb0RAD6D oGiC89G8K9TgD+8zNKyaWbSL9OOEJrIFr8e3QTngFIeKYIPscWkAfaNvlte3Fo2XC7k5 mOog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+yYB+UjJ5L6aV3imoGiJTko2w0CvVVRSooT6AuiAzyA=; b=KN/+POgsjGR5YrvRC7TTppZO5WpH2qpJoMNRjp8uo0ezktP4ay8SYp8gYaCZkdd/jM G2+7B/9Atwv6qpQTigmeUPI1wz/ENVDvG8TE6xzp0prNMfRhRFtDT7TPAwS26kkA3PmK Q37hUJ94IlK4Akqfs+VWVmA8XRqdSQBluD0/a5p+S9H4+CXEbqj0ug+riggogKz5rYGX YUbSF+zTwPlFOQsK1NGa41EwrYfiakSJ1pOCTXDKnMyIj2BBWBjti42GQLVGlBRA6xTt /EOarW3AMPwt1JFONeQ/hddC4gqdu+sOdSCphnNQxXCXxc0qzqobhOVaP39gRAWKN3tq s4WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UPBfEiuB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a3-20020a63e843000000b0051372ec9316si12492738pgk.166.2023.04.12.11.51.56; Wed, 12 Apr 2023 11:52:23 -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=@gmail.com header.s=20221208 header.b=UPBfEiuB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbjDLSpS (ORCPT + 99 others); Wed, 12 Apr 2023 14:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjDLSpL (ORCPT ); Wed, 12 Apr 2023 14:45:11 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF4B61B3 for ; Wed, 12 Apr 2023 11:45:10 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-1842eb46746so14785314fac.4 for ; Wed, 12 Apr 2023 11:45:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681325109; x=1683917109; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+yYB+UjJ5L6aV3imoGiJTko2w0CvVVRSooT6AuiAzyA=; b=UPBfEiuB141JD/GXIrwt1YK0IqNU31AQsFYZPMxST7mtTUkUIBz3ZeAm4bS3Pk5j0f n+A0ASxR98pgRMV0FPqJo/FUBmSaCGvGOhEnmb2MSDDUxCfFPb2W4xW2HwZQeor+EC4o pVmfVfIu4DJC8gOR0L/mRn60h9QGKrwqsQB6Z6Z6KsFCxHGz+F+9gBTTm6m0lrfavKQF R9Cr8FFG+UzTfnQr0drhQYNUVWUshzRjPE+rSLpFSUDmRbJuoa/ZWeEEn1Jb3SiC8rO+ FHhEewf4EdlsrOsogtmESpZOLk68uoU9tO2oLLQymnmJP20+WAiQkZqg8ukHFFxIAfAs ATkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681325109; x=1683917109; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+yYB+UjJ5L6aV3imoGiJTko2w0CvVVRSooT6AuiAzyA=; b=H7UmIf2/m7y0qtMa2BwadG0QYCdlDNQLp2VN247Ola9C+BmapnqBIY9aFQOmjuCP3S Z6vTs6XLha+vHWTWdNdU2KV2BJjiHJjduX8kndaBTHpxj7KZ1DoUzzTzo05ah0p/RgD4 Ag9vzEWuev4fDyAK3GsNHI+Ul4kDekrE+J9IDjlljd5PFc8MeVCzthg23NbAE0vwEU14 KCpquOdPVBoAWTYNyeJ8ssYJIDbNgBQKm7r+QhPRbHa5h1FbDrrsWTAeg84vlpiT9KEL wXmLLcsKgURJLSiWsHEYGDQGfQs3xQfoda2Nh7d9gmn9+lrOXZFjNOuEhwy+6aqa9XKu CBbA== X-Gm-Message-State: AAQBX9e+9r/9HvqPIHkR1H1R6pyE0JJhaqdLOoouJkwXyJfO+NOcBDqH 9heOqfFrWoeIRK1rKJWuqXobm5dylA== X-Received: by 2002:a05:6870:969e:b0:180:13a4:425e with SMTP id o30-20020a056870969e00b0018013a4425emr4222567oaq.30.1681325109407; Wed, 12 Apr 2023 11:45:09 -0700 (PDT) Received: from citadel.. (075-129-116-198.res.spectrum.com. [75.129.116.198]) by smtp.gmail.com with ESMTPSA id w24-20020a9d77d8000000b00690e990e61asm6706020otl.14.2023.04.12.11.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 11:45:08 -0700 (PDT) From: Brian Gerst To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Borislav Petkov , "H . Peter Anvin" , Peter Zijlstra , Ingo Molnar , Brian Gerst Subject: [PATCH v2 0/6] x86/boot: Clean up handling of boot_params pointer Date: Wed, 12 Apr 2023 14:44:56 -0400 Message-Id: <20230412184502.145289-1-brgerst@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762997613399035131?= X-GMAIL-MSGID: =?utf-8?q?1762997613399035131?= On entry from the bootloader, RSI contains the pointer to the boot_params data structure. The pointer is passed to x86_64_start_kernel(), which requires preserving RSI all the way though the early boot asm code. Change it to copy the boot_params data as soon as possible, which also has the benefit of not needing to remap the real mode data pages if memory encryption is enabled. Note: The memory encryption changes are untested due to lack of hardware. Brian Gerst (6): x86/boot: Move sanitize_boot_params() x86/boot: Remove extra call to copy_bootdata() x86/boot: Clean up get_cmd_line_ptr() x86/boot: Move copy_bootdata() to very early boot. x86/boot: Use copied boot data in __startup_64() x86/boot: Use copied boot data in sme_enable() arch/x86/include/asm/mem_encrypt.h | 4 +- arch/x86/include/asm/setup.h | 9 +++-- arch/x86/kernel/head64.c | 59 ++++++++++------------------- arch/x86/kernel/head_64.S | 26 +++---------- arch/x86/kernel/setup.c | 2 +- arch/x86/mm/mem_encrypt_amd.c | 61 ------------------------------ arch/x86/mm/mem_encrypt_identity.c | 42 ++++++++++---------- arch/x86/xen/enlighten_pv.c | 2 +- 8 files changed, 58 insertions(+), 147 deletions(-)