Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp640705rwi; Wed, 19 Oct 2022 00:34:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4c/Yp6Xsl4apBq8wQPU9mi+ctXoR/MeRuMJOuqEoZgZDUl9/HRSeNnMI/XgZq1c2WORMcY X-Received: by 2002:a17:906:fc6:b0:72f:d080:416 with SMTP id c6-20020a1709060fc600b0072fd0800416mr5668445ejk.1.1666164868983; Wed, 19 Oct 2022 00:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666164868; cv=none; d=google.com; s=arc-20160816; b=iJq17d1YYqkc+VbtmEG/QqiJb6QUylDDcwqH64ugpExVbyRigMkalvc9R3tuiJrQX2 uLrVitnr41iiTyd8VarlLLFGAhZzInH5MEtnblXeeGF5I+eCrPIpYzV4LzuhnhkGllBx ynrlXSKI8WQLupPdxPLwRDK1ZOZwbkl+xfNtnM8Qmg9EZLWG8Hu8Za3UFaTjI4iDJQlW 4O1LUQBklf+ODOhveAj9dl71+BCdPhON6r19kPHJeuyxXPGf5EtBgSy/cZWASCO8cGh0 EagW2nq3dbQGlaqtQT0RO07sV1BbJHbb+MBxG1PY0BRJwxD2//qgavrZY/xkqYO67EHk 7VFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JBuRydEWzZLCSv2/lgOt8pMLA4JH24jr31vjo9CpyU8=; b=IQAi38t+WQRoShaY9cM9TJYxNs2lDvlSxKHbuakBWVawlJXWDVJTLc98gyerAw3mND VRKqnH5+WymRKlgbgN4J4VsXvmEImJg67GoBTtAEVdGcIQWf/ESQibAdzqZrN/yir/yr 3VitzlUo9OgbEJY57JYPaHTvoJGI2QCW1bIyLaZl2tdoHnAeGeeBS38mN8RTxYd2I+EP q03ck1oACFOkIA5rAe9zBI7xjP6DHwF6NDVhFO2qs1fa/Fa343xRXeWK4elgbwIiQZ5Z hK8PsZaG03RfS1zpZ8Yyh0plSOBknx46Br0Cm8gQxsskHC9lJKiKtJr3yMG31iLW4iDZ RjxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rth+6yIa; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne41-20020a1709077ba900b00780328a0868si13602646ejc.110.2022.10.19.00.34.01; Wed, 19 Oct 2022 00:34:28 -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=@kernel.org header.s=k20201202 header.b=rth+6yIa; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230002AbiJSHVA (ORCPT + 99 others); Wed, 19 Oct 2022 03:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbiJSHUv (ORCPT ); Wed, 19 Oct 2022 03:20:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25E0773C30; Wed, 19 Oct 2022 00:20:48 -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 7D5AC6179B; Wed, 19 Oct 2022 07:20:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0733C43470; Wed, 19 Oct 2022 07:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666164047; bh=of0ZAKA9tXwjIpzkLxVj0WEzoODLE+HML3Zt/NyW1FI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=rth+6yIaIPUoMoM1pxucaWlgEMssAO8Eru2d0JwqA3zpx1ntiE3YBzXYseEVpxEW1 Te8mnjIjNvDTSKzNnhxdq4NtkS3sGrrX4YS78GMWNTR40Y/+meT+D6rV3uuvYuB6T4 Gw8/tr+OQwlVGJfjYrpxxpHZTfJ7CJREowoiRS6Z4EbVDqol3rDoo0dHQXxJo650kV 32MmU5AZaFqlIgRr2IoWEWHT3ssDT9S3UpGsXSsAvY89uPxXutEAGrGP8+BRGjHXVT VXgWDHzvPBLmCS690TSGaRF4uxkxFCMhHYAHlURsbAs7C1KuCiFb5zCRH2CW1CyrJu xq8cd//S49iFg== Received: by mail-lj1-f175.google.com with SMTP id a6so21001584ljq.5; Wed, 19 Oct 2022 00:20:47 -0700 (PDT) X-Gm-Message-State: ACrzQf3NXTmJUzlQAYvxZIV/ymhMsLGMMnLsYKWv8qG89c7faCSZzTVr vZpU6AqsoNMBtMSiKEuAjGfFwi021BC2YzF00MA= X-Received: by 2002:a05:651c:1590:b0:26c:4311:9b84 with SMTP id h16-20020a05651c159000b0026c43119b84mr2566040ljq.152.1666164045946; Wed, 19 Oct 2022 00:20:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Wed, 19 Oct 2022 09:20:34 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 08/16] x86/boot: Remove mapping from page fault handler To: Evgeniy Baskov Cc: Borislav Petkov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , lvc-project@linuxtesting.org, x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Tue, 6 Sept 2022 at 12:41, Evgeniy Baskov wrote: > > After every implicit mapping is removed, this code is no longer needed. > > Remove memory mapping from page fault handler to ensure that there are > no hidden invalid memory accesses. > > Signed-off-by: Evgeniy Baskov I don't grok this 100% but to me, it seems not having to rely on a page fault handler to ensure that the 1:1 mapping has sufficient coverage is a win so Acked-by: Ard Biesheuvel > --- > arch/x86/boot/compressed/ident_map_64.c | 26 ++++++++++--------------- > 1 file changed, 10 insertions(+), 16 deletions(-) > > diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c > index 880e08293023..c20cd31e665f 100644 > --- a/arch/x86/boot/compressed/ident_map_64.c > +++ b/arch/x86/boot/compressed/ident_map_64.c > @@ -385,27 +385,21 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code) > { > unsigned long address = native_read_cr2(); > unsigned long end; > - bool ghcb_fault; > + char *msg; > > - ghcb_fault = sev_es_check_ghcb_fault(address); > + if (sev_es_check_ghcb_fault(address)) > + msg = "Page-fault on GHCB page:"; > + else > + msg = "Unexpected page-fault:"; > > address &= PMD_MASK; > end = address + PMD_SIZE; > > /* > - * Check for unexpected error codes. Unexpected are: > - * - Faults on present pages > - * - User faults > - * - Reserved bits set > - */ > - if (error_code & (X86_PF_PROT | X86_PF_USER | X86_PF_RSVD)) > - do_pf_error("Unexpected page-fault:", error_code, address, regs->ip); > - else if (ghcb_fault) > - do_pf_error("Page-fault on GHCB page:", error_code, address, regs->ip); > - > - /* > - * Error code is sane - now identity map the 2M region around > - * the faulting address. > + * Since all memory allocations are made explicit > + * now, every page fault at this stage is an > + * error and the error handler is there only > + * for debug purposes. > */ > - kernel_add_identity_map(address, end, MAP_WRITE); > + do_pf_error(msg, error_code, address, regs->ip); > } > -- > 2.35.1 >