linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: yaoaili126@163.com
Cc: rjw@rjwysocki.net, lenb@kernel.org, tony.luck@intel.com,
	bp@alien8.de, linux-acpi@vger.kernel.org, yangfeng1@kingsoft.com,
	yaoaili@kingsoft.com
Subject: Re: [PATCH] Fix incorrect return value of pre_map_gar_callback
Date: Wed, 28 Oct 2020 19:19:28 +0000	[thread overview]
Message-ID: <6b71b5b3-b423-6768-15f4-44f7aa7dc12d@arm.com> (raw)
In-Reply-To: <20201026061509.48212-1-yaoaili126@163.com>

Hi!

On 26/10/2020 06:15, yaoaili126@163.com wrote:
> From: Aili Yao <yaoaili@kingsoft.com>
> 
> From commit 6915564dc5a8 ("ACPI: OSL: Change the type of
> acpi_os_map_generic_address() return value"),acpi_os_map_generic_address
> will return logical address or NULL for error, but pre_map_gar_callback,for
> ACPI_ADR_SPACE_SYSTEM_IO case, it should

'it should' refers to pre_map_gar_callback(), not acpi_os_map_generic_address()?


> be also return 0,as it's a
> normal case, but now it will return -ENXIO. so check it out for such case
> to avoid einj module initialization fail.

apei_map_generic_address() calls acpi_os_map_generic_address() which returns NULL for any
address space that isn't ACPI_ADR_SPACE_SYSTEM_MEMORY.
That commit now maps this to an error code, where-as before: this code was getting away
with it.

The bug is it tries to map a GAR that doesn't need mapping.


Could we avoid this problem more clearly by returning 0 from apei_map_generic_address()
for address spaces that don't need mapping? (e.g. IO)

This would also fix any other callers lurking in apei.


Thanks,

James


> diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
> index 552fd9ffaca4..042d2dbdb855 100644
> --- a/drivers/acpi/apei/apei-base.c
> +++ b/drivers/acpi/apei/apei-base.c
> @@ -230,7 +230,8 @@ static int pre_map_gar_callback(struct apei_exec_context *ctx,
>  {
>  	u8 ins = entry->instruction;
>  
> -	if (ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER)
> +	if (ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER &&
> +	 entry->register_region.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
>  		return apei_map_generic_address(&entry->register_region);
>  
>  	return 0;



  parent reply	other threads:[~2020-10-29  2:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26  6:15 [PATCH] Fix incorrect return value of pre_map_gar_callback yaoaili126
2020-10-26 16:59 ` Luck, Tony
2020-10-28 19:19 ` James Morse [this message]
     [not found] <6b71b5b3-b423-6768-15f4-44f7aa7dc12d () arm ! com>
2020-10-29 11:30 ` yaoaili126
2020-10-30 14:03   ` James Morse

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=6b71b5b3-b423-6768-15f4-44f7aa7dc12d@arm.com \
    --to=james.morse@arm.com \
    --cc=bp@alien8.de \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=tony.luck@intel.com \
    --cc=yangfeng1@kingsoft.com \
    --cc=yaoaili126@163.com \
    --cc=yaoaili@kingsoft.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;
as well as URLs for NNTP newsgroup(s).