Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1109492pxm; Thu, 3 Mar 2022 10:27:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxz8k/WGe8P2tXS9hgyHY//hHcU8eGhHqT7pMr2hzr9iFO2HR762HON9DPgmyUNSOKihVMY X-Received: by 2002:a17:90a:e512:b0:1bc:22c8:cc82 with SMTP id t18-20020a17090ae51200b001bc22c8cc82mr6655588pjy.208.1646332079657; Thu, 03 Mar 2022 10:27:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646332079; cv=none; d=google.com; s=arc-20160816; b=CvCrdtO8JAP/9ymvOPOeCCMIxKp3ZQgweyy0FrJa4IFdSfNboyn85ibhoJPG4J2en6 tqMSnG4ZfTFTrDUWT9PURSDR23u9x3pqOpamYJbIANQTONY/3PwmAxRxr0paB1o6nWNj p7FMxsrl3yevify67FtAwICJfWEvS2FyAixLTFdajp4MNg70UpqI8Cx3SUjGg8vzZAFF N2nOroTsa9lLWSyeMYR+jBwzAdY4j1vI7ADYG/kYy42jSo+hkr9Efj8190g76f2x9P+E 69ik7Mslq0n3p9PaBLyUpMOU0hnXZ2O7t8nAn799oqfdcnGjC5vHNVOZLIBDJqZ3N8gS i7hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version; bh=HphQSmE08Vb5hMRe1IvYMqwrVCl6JmWopNlwRKAJqwo=; b=mN6GUzlHOMtG2rEHxm0otFxvFtSuIleMZgBXZl2c907nXz/qlcRms8MRsNeSMVmeIm Xf/OrTWn7VbMSpD5wfUew+udpR2YEqfwbbfI4ccxSI242jCqGfaoFGIIXft1YE+CIjPX 7nsLfASNwIxRezroWLNR3k133zQpJp6ycn6HTlMkvav+ITeLYuagequlV21tEXQfe4kd h0oAEVkpOL52PR14VzdMZ5IiI4TNjQ6OLOU0AMLy17qhl9+7rFQl57DPe1isL2rFXN2T /TjxEEq02MvAfzHVzGbYNYY3r4Vll8ytDPOKGTn1oTaZUzaxuqCq0udelDN23fTslAIk llWw== ARC-Authentication-Results: i=1; mx.google.com; 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=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a63df08000000b003657e94cb9bsi2787568pgg.542.2022.03.03.10.27.43; Thu, 03 Mar 2022 10:27:59 -0800 (PST) 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; 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=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233526AbiCCOQj (ORCPT + 99 others); Thu, 3 Mar 2022 09:16:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbiCCOQf (ORCPT ); Thu, 3 Mar 2022 09:16:35 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AD7218CC65; Thu, 3 Mar 2022 06:15:48 -0800 (PST) Received: from mail.ispras.ru (unknown [83.149.199.84]) by mail.ispras.ru (Postfix) with ESMTPSA id AB11A40755C1; Thu, 3 Mar 2022 14:15:46 +0000 (UTC) MIME-Version: 1.0 Date: Thu, 03 Mar 2022 17:15:46 +0300 From: baskov@ispras.ru To: Ard Biesheuvel Cc: Matthew Garrett , Peter Jones , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , linux-efi , Linux Kernel Mailing List Subject: Re: [PATCH RFC v2 0/2] Handle UEFI NX-restricted page tables In-Reply-To: References: <20220224154330.26564-1-baskov@ispras.ru> User-Agent: Roundcube Webmail/1.4.4 Message-ID: <773b799354b50adf854837d8a6d54b8f@ispras.ru> X-Sender: baskov@ispras.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 2022-02-28 19:45, Ard Biesheuvel wrote: > (cc Matt and Peter) > > > Thanks for exploring my suggestion to use the DXE services for this. > > Given that this is a workaround for a very specific issue arising on > PI based implementations of UEFI, I consider this a quirk, and so I > think this approach is reasonable. I'd still like to gate it on some > kind of identification, though - perhaps something related to DMI like > the x86 core kernel does as well. > > I've cc'ed Peter and Matt, who have much more experience dealing with > these kinds of things on x86 - my experience is mostly based on ARM, > which tends to be less quirky when it comes to UEFI support, given > that vendors that implement EFI actually care about being compliant > (instead of only about getting a windows sticker) > > Matt, Peter, any thoughts? > > >> Baskov Evgeniy (2): >> efi: declare DXE services table >> libstub: ensure allocated memory to be executable >> >> arch/x86/include/asm/efi.h | 5 ++ >> drivers/firmware/efi/libstub/efistub.h | 53 ++++++++++++++++++++ >> drivers/firmware/efi/libstub/x86-stub.c | 73 >> ++++++++++++++++++++++++++-- >> include/linux/efi.h | 2 + >> 4 files changed, 128 insertions(+), 5 deletions(-) We now have tested the patch on major platforms, and it works without any issues. But in case of firmware bugs I have changed the code to only modify attributes if either EFI_MEMORY_RO or EFI_MEMORY_WP is set and the memory has type EfiGcdMemoryTypeSystemMemory. I also added option CONFIG_EFI_DXE_MEM_ATTRIBUTES (enabled by default), to allow this code to be disabled at compile time. These changes will be sent in version 3 of the patch. Thanks, Baskov Evgeniy