public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Koba Ko <kobak@nvidia.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Matt Ochs <mochs@nvidia.com>, James Morse <james.morse@arm.com>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zhang Rui <rui.zhang@intel.com>,
	linux-efi@vger.kernel.org
Subject: Re: [PATCH V8] acpi/prmt: find block with specific type
Date: Sun, 13 Oct 2024 03:38:11 +0800	[thread overview]
Message-ID: <21b2162d-bb6c-4aa9-b747-d9bb2e6d6402@nvidia.com> (raw)
In-Reply-To: <CAMj1kXE2D56oYP4mPzBxCzjiUH34HfhnWeBcbzL_gYWdvy0j7g@mail.gmail.com>


On 10/13/24 03:36, Ard Biesheuvel wrote:
> External email: Use caution opening links or attachments
>
>
> On Sat, 12 Oct 2024 at 21:16, KobaK <kobak@nvidia.com> wrote:
>> From: Koba Ko <kobak@nvidia.com>
>>
>> PRMT needs to find the correct type of block to
>> translate the PA-VA mapping for EFI runtime services.
>>
>> The issue arises because the PRMT is finding a block of
>> type EFI_CONVENTIONAL_MEMORY, which is not appropriate for
>> runtime services as described in Section 2.2.2 (Runtime
>> Services) of the UEFI Specification [1]. Since the PRM handler is
>> a type of runtime service, this causes an exception
>> when the PRM handler is called.
>>
>>      [Firmware Bug]: Unable to handle paging request in EFI runtime service
>>      WARNING: CPU: 22 PID: 4330 at drivers/firmware/efi/runtime-wrappers.c:341
>>          __efi_queue_work+0x11c/0x170
>>      Call trace:
>>
>> Find a block with specific type to fix this.
>> PRMT find a block with EFI_MEMORY_RUNTIME for PRM handler and PRM context.
>> If no suitable block is found, a warning message will be prompted
>> but the procedure continues to manage the next PRM handler.
>> However, if the PRM handler is actually called without proper allocation,
>> it would result in a failure during error handling.
>>
>> By using the correct memory types for runtime services,
>> ensure that the PRM handler and the context are
>> properly mapped in the virtual address space during runtime,
>> preventing the paging request error.
>>
>> The issue is really that only memory that has been remapped for
>> runtime by the firmware can be used by the PRM handler, and so the
>> region needs to have the EFI_MEMORY_RUNTIME attribute.
>>
>> [1] https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf
>> Fixes: cefc7ca46235 ("ACPI: PRM: implement OperationRegion handler for the PlatformRtMechanism subtype")
>> cc: stable@vger.kernel.org
>> Signed-off-by: Koba Ko <kobak@nvidia.com>
>> Reviewed-by: Matthew R. Ochs <mochs@nvidia.com>
>> Reviewed-by: Zhang Rui <rui.zhang@intel.com>
>> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
>> ---
>> V2:
>> 1. format the changelog and add more about error handling.
>> 2. replace goto
>> V3: Warn if parts of handler are missed during va-pa translating.
>> V4: Fix the 0day
>> V5: Fix typo and pr_warn warning
>> V6: use EFI_MOMOERY_RUNTIME to find block and split goto refactor as a single
>> patch
>> V7:
>> 1. refine the codes and commit description as per comments
>> 2. drop goto refacotr
>> V8: Fix 0day and cc to stable
> 'fix 0day' means nothing - please describe what the actual change is
> compared to the previous version.
Thanks, will do it in v9
>> ---
>>   drivers/acpi/prmt.c | 27 ++++++++++++++++++++++-----
>>   1 file changed, 22 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/acpi/prmt.c b/drivers/acpi/prmt.c
>> index 1cfaa5957ac4..552442bc10fd 100644
>> --- a/drivers/acpi/prmt.c
>> +++ b/drivers/acpi/prmt.c
>> @@ -72,17 +72,21 @@ struct prm_module_info {
>>          struct prm_handler_info handlers[] __counted_by(handler_count);
>>   };
>>
>> -static u64 efi_pa_va_lookup(u64 pa)
>> +static u64 efi_pa_va_lookup(efi_guid_t *guid, u64 pa)
>>   {
>>          efi_memory_desc_t *md;
>>          u64 pa_offset = pa & ~PAGE_MASK;
>>          u64 page = pa & PAGE_MASK;
>>
>>          for_each_efi_memory_desc(md) {
>> -               if (md->phys_addr < pa && pa < md->phys_addr + PAGE_SIZE * md->num_pages)
>> +               if ((md->attribute & EFI_MEMORY_RUNTIME) &&
>> +                   (md->phys_addr < pa && pa < md->phys_addr + PAGE_SIZE * md->num_pages)) {
>>                          return pa_offset + md->virt_addr + page - md->phys_addr;
>> +               }
>>          }
>>
>> +       pr_warn("Failed to find VA for GUID: %pUL, PA: %p", guid, (void *)pa);
>> +
> 'pa' is not a pointer so don't treat it as one - please drop the cast,
> and use 0x%llx as the format specifier.

      reply	other threads:[~2024-10-12 19:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-12 19:16 [PATCH V8] acpi/prmt: find block with specific type KobaK
2024-10-12 19:36 ` Ard Biesheuvel
2024-10-12 19:38   ` Koba Ko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21b2162d-bb6c-4aa9-b747-d9bb2e6d6402@nvidia.com \
    --to=kobak@nvidia.com \
    --cc=ardb@kernel.org \
    --cc=james.morse@arm.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochs@nvidia.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox