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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A018C433EF for ; Mon, 31 Jan 2022 19:03:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.263271.455936 (Exim 4.92) (envelope-from ) id 1nEbxX-0006uc-EW; Mon, 31 Jan 2022 19:03:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 263271.455936; Mon, 31 Jan 2022 19:03:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nEbxX-0006uV-Bb; Mon, 31 Jan 2022 19:03:27 +0000 Received: by outflank-mailman (input) for mailman id 263271; Mon, 31 Jan 2022 19:03:26 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nEbxW-0006uP-8r for xen-devel@lists.xenproject.org; Mon, 31 Jan 2022 19:03:26 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nEbxS-0001NZ-Ls; Mon, 31 Jan 2022 19:03:22 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=[10.95.141.2]) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nEbxS-0001Az-FX; Mon, 31 Jan 2022 19:03:22 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=kww/5U+siM2skOKPUMWbZZ4Lk0cz4BzU3DwFzwYF6QA=; b=pJhNq0fLRqXvgMww40V1QmAVBW wTXb6Ef2S1jsmuHeicWPSYBiFA2JfogEeySiLjE4vIdOeN3PAzkE4g5RDlVtAHqkKgUILvx7rED1D t/P/yH06CC0UcqnuRIc1EQv3DkDD77sB1qecJHJ3k+7nGCr+M5v7+AmHBcmotnUpY6k8=; Message-ID: Date: Mon, 31 Jan 2022 19:03:20 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v4] EFI: always map EfiRuntimeServices{Code,Data} To: Jan Beulich Cc: Andrew Cooper , George Dunlap , Stefano Stabellini , Wei Liu , Sergey Temerkhanov , "xen-devel@lists.xenproject.org" References: <89d182f6-95e8-674a-2297-6e98435385f8@suse.com> <2860d074-ecfb-273a-88c7-391e3297ccba@suse.com> From: Julien Grall In-Reply-To: <2860d074-ecfb-273a-88c7-391e3297ccba@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Jan, On 27/01/2022 12:25, Jan Beulich wrote: > On 27.01.2022 11:45, Julien Grall wrote: >> On 12/01/2022 08:45, Jan Beulich wrote: >>> From: Sergey Temerkhanov >>> >>> This helps overcome problems observed with some UEFI implementations >> >> Would it be possible to provide some details about the platform? This is >> helpful to track why a workaround is present. > > I cannot provide any details. I took over the patch after pinging > Sergey more than once, without any reaction. It was him to actually > run into the problem in the wild. This is a quite unfortunate. > >>> which don't set the Attributes field in memery descriptors properly. >> >> typo: s/memery/memory/ >> >>> >>> Signed-off-by: Sergey Temerkhanov >>> Signed-off-by: Jan Beulich >>> --- >>> v4: Drop EFI_MEMORY_CACHEABILITY_MASK. Fold with pre-existing if() (into >>> switch()). Style. >>> --- >>> I guess "map_bs" would also want honoring in efi_exit_boot(), but that's >>> yet another patch then I suppose. >> >> IIUC, we would need to invalidate the mapping when map_bs was used. Is >> it correct? If so, then I agree this sounds separate to the issue you >> are describing here. > > No, the other way around: We'd also need to put in a valid virtual > address there for EfiBootServices{Code,Data}. I expect this wasn't > done when map_bs was introduced because iirc at that time the code > fragment in efi_exit_boot() was entirely dead, present merely for > documentation purposes. > >>> --- a/xen/common/efi/boot.c >>> +++ b/xen/common/efi/boot.c >>> @@ -1094,7 +1094,13 @@ static void __init efi_exit_boot(EFI_HAN >>> { >>> EFI_MEMORY_DESCRIPTOR *desc = efi_memmap + i; >>> >>> - if ( desc->Attribute & EFI_MEMORY_RUNTIME ) >>> + /* >>> + * Runtime services regions are always mapped here. >>> + * Attributes may be adjusted in efi_init_memory(). >>> + */ >>> + if ( (desc->Attribute & EFI_MEMORY_RUNTIME) || >>> + desc->Type == EfiRuntimeServicesCode || >>> + desc->Type == EfiRuntimeServicesData ) >> >> My knowledge with the stub is limited. Would you be able to explain why >> we need to map the runtime services even with !efi_enabled(EFI_RS)? > > In principle we wouldn't need to, but the final setting of this bit > isn't known yet at this point - it'll be known only after parsing > the command line (see parse_efi_param()). Oh. I thought efi_exit_boot() was called *after* efi_init_memory(). Your answer about 'map_bs' also make more sense. Thanks for the explanation! Reviewed-by: Julien Grall Cheers, -- Julien Grall