All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-15 21:42 Al Stone
  0 siblings, 0 replies; 10+ messages in thread
From: Al Stone @ 2015-06-15 21:42 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 5618 bytes --]

On 06/14/2015 07:13 PM, Zheng, Lv wrote:
> Hi,
> 
>> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Zheng, Lv
>> Sent: Monday, June 15, 2015 8:49 AM
>>
>> Hi,
>>
>>> From: Zheng, Lv
>>> Sent: Monday, June 15, 2015 8:40 AM
>>>
>>> Hi,
>>>
>>>> From: Al Stone [mailto:ahs3(a)redhat.com]
>>>> Sent: Saturday, June 13, 2015 6:00 AM
>>>>
>>>> On 06/09/2015 12:16 AM, Zheng, Lv wrote:
>>>>> Hi,
>>>>>
>>>>> The patch is wrong.
>>>>> If we want to dump tables without accessing /dev/mem, we have acpidump -c.
>>>>> The only problem here is:
>>>>> There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
>>>>> So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.
>>>>>
>>>>> We've noticed the similar issue in handling this kernel bug:
>>>>> https://bugzilla.kernel.org/show_bug.cgi?id=87971
>>>>> The fix for this issue can be found here:
>>>>> https://github.com/acpica/acpica/pull/77
>>>>>
>>>>> Thanks and best regards
>>>>> -Lv
>>>>
>>>> The problem I have with this fix for the issue is that this command:
>>>>
>>>> 	# acpidump -n APIC
>>>>
>>>> will work on x86 but fail on arm64.  Getting the -c option to work properly
>>>> is a good thing, and should be done regardless.  But, this means we have to
>>>> use "acpidump -c -n APIC" on systems without /dev/mem.  For my part:
>>>>
>>>>    (a) these are not really customized tables, but the standard ACPI tables
>>>>        used to boot the system, so using -c is a little confusing, and
>>>>
>>>>    (b) we now have to use different commands on different architectures to
>>>>        get the same result.
>>>>
>>>> My preference would be that the same command has the same behavior everywhere,
>>>> which is why I patched it the way I did.
>>>
>>> This is not our preference, though...
>>> I've been in the trouble of being easily confused by the bug reporters.
>>> And I cannot distinguish if the table has been customized or root cause the bugs if the reporter did what I asked for but hid what he
>>> silently did.
>>> If we cannot distinguish the BIOS provided tables and the user customized tables from users' output, we'll likely lose the capability of
>>> taking evidence...
>>>
>>>>
>>>> This happens to be very useful on arm64 where /dev/mem is not reliable, but it
>>>> could also be usable on any system that does not want to expose /dev/mem for
>>>> some reason.  I think the advantage of the patch sent is that the user command
>>>> stays the same no matter what the situation.
>>>
>>> My suggestion would be to support this via kernel.
>>> Let the kernel exposes 2 kind of tables (customized or not customized) into the /sys/firmware/acpi/tables.
>>> Which can meet both of the requirements.
>>
>> Or we currently can make the "-c" mode the default behavior and add a new option for dumping the BIOS tables.
> 
> And you can check if this commit is acceptable:
> https://github.com/acpica/acpica/pull/80

Hrm.  I guess if we have to have the -c option, I would prefer the first patch
where we just get rid of the dependence on /dev/mem.  I think it is easier to
explain that -c must always be used rather than trying to explain how to use
the -c on/off options.

I think the path I would like to see long term is to split up /sys as you
suggested so that there is a run-time version of the ACPI tables, and a copy
of the tables from UEFI.  That way, no one has to rely on /dev/mem at all,
and acpidump can go back to parameters operating exactly the same way on all
possible platforms.

> Thanks and best regards
> -Lv
> 
>>
>> Thanks and best regards
>> -Lv
>>
>>
>>>
>>> Thanks and best regards
>>> -Lv
>>>
>>>>
>>>>>> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
>>>>>> Sent: Thursday, June 04, 2015 8:43 AM
>>>>>>
>>>>>> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
>>>>>> contents may or may not be valid depending on the memory map being used, since
>>>>>> they are not standardized.
>>>>>>
>>>>>> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
>>>>>> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
>>>>>> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
>>>>>> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
>>>>>> that the tables retrieved are the ones actually being used and that their
>>>>>> content is correct.
>>>>>>
>>>>>> This patch applies on top of the 20150515 version, and I have included it in
>>>>>> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
>>>>>> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
>>>>>>
>>>>>> Signed-off-by: Al Stone <ahs3(a)redhat.com>
>>>>>>
>>>>>> --
>>>>>> ciao,
>>>>>> al
>>>>>> -----------------------------------
>>>>>> Al Stone
>>>>>> Software Engineer
>>>>>> Red Hat, Inc.
>>>>>> ahs3(a)redhat.com
>>>>>> -----------------------------------
>>>>
>>>>
>>>> --
>>>> ciao,
>>>> al
>>>> -----------------------------------
>>>> Al Stone
>>>> Software Engineer
>>>> Red Hat, Inc.
>>>> ahs3(a)redhat.com
>>>> -----------------------------------
>> _______________________________________________
>> Devel mailing list
>> Devel(a)acpica.org
>> https://lists.acpica.org/mailman/listinfo/devel


-- 
ciao,
al
-----------------------------------
Al Stone
Software Engineer
Red Hat, Inc.
ahs3(a)redhat.com
-----------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-16  0:41 Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2015-06-16  0:41 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 7135 bytes --]

Hi,

> From: Al Stone [mailto:ahs3(a)redhat.com]
> Sent: Tuesday, June 16, 2015 5:37 AM
> 
> On 06/14/2015 06:39 PM, Zheng, Lv wrote:
> > Hi,
> >
> >> From: Al Stone [mailto:ahs3(a)redhat.com]
> >> Sent: Saturday, June 13, 2015 6:00 AM
> >>
> >> On 06/09/2015 12:16 AM, Zheng, Lv wrote:
> >>> Hi,
> >>>
> >>> The patch is wrong.
> >>> If we want to dump tables without accessing /dev/mem, we have acpidump -c.
> >>> The only problem here is:
> >>> There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
> >>> So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.
> >>>
> >>> We've noticed the similar issue in handling this kernel bug:
> >>> https://bugzilla.kernel.org/show_bug.cgi?id=87971
> >>> The fix for this issue can be found here:
> >>> https://github.com/acpica/acpica/pull/77
> >>>
> >>> Thanks and best regards
> >>> -Lv
> >>
> >> The problem I have with this fix for the issue is that this command:
> >>
> >> 	# acpidump -n APIC
> >>
> >> will work on x86 but fail on arm64.  Getting the -c option to work properly
> >> is a good thing, and should be done regardless.  But, this means we have to
> >> use "acpidump -c -n APIC" on systems without /dev/mem.  For my part:
> >>
> >>    (a) these are not really customized tables, but the standard ACPI tables
> >>        used to boot the system, so using -c is a little confusing, and
> >>
> >>    (b) we now have to use different commands on different architectures to
> >>        get the same result.
> >>
> >> My preference would be that the same command has the same behavior everywhere,
> >> which is why I patched it the way I did.
> >
> > This is not our preference, though...
> > I've been in the trouble of being easily confused by the bug reporters.
> > And I cannot distinguish if the table has been customized or root cause the bugs if the reporter did what I asked for but hid what he
> silently did.
> > If we cannot distinguish the BIOS provided tables and the user customized tables from users' output, we'll likely lose the capability of
> taking evidence...
> 
> Understood; I was in technical support roles for many years.
> 
> Perhaps I am misunderstanding this use of the word "customized."  On ARM, the
> only way I can be sure to get the tables supplied by UEFI is to use the UEFI
> shell and dump them.  Once the OS has booted, the tables in /sys/firmware/acpi
> are what the system is currently using, and those are the ones I'm interested
> in using for debugging when something breaks.  So, unless I have replaced the
> DSDT in the initrd, or added SSDTs, /sys/firmware/acpi will be exactly the same
> as what UEFI provided.  Even then, those are the tables I want to see if there
> is a problem since those are the ones being used.  Is that what "customized"
> means, in this case: the actual run-time tables and not the tables provided by
> UEFI?

Yes, so the "customized" tables should be dumped by default as you've suggested.

> 
> >> This happens to be very useful on arm64 where /dev/mem is not reliable, but it
> >> could also be usable on any system that does not want to expose /dev/mem for
> >> some reason.  I think the advantage of the patch sent is that the user command
> >> stays the same no matter what the situation.
> >
> > My suggestion would be to support this via kernel.
> > Let the kernel exposes 2 kind of tables (customized or not customized) into the /sys/firmware/acpi/tables.
> > Which can meet both of the requirements.
> 
> Okay, this sort of answers my questions.  "Customized" is not the word I would
> have chosen for this -- I think I would have made it
> /sys/firmware/acpi/tables/current (i.e., "customized") and
> /sys/firmware/acpi/tables/boot (i.e.,
> not "customized").  When I was thinking of tables as being customized, I was
> thinking of new versions of all kinds of tables, not just the DSDT and SSDTs.
> On ARM, going in and out of ACPI mode is just not allowed so there's really no
> opportunity to customize the tables much, other than adding SSDTs.
> 
> Creating new sysfs entries in a kernel driver would be simple enough to do;
> the issue would be getting it accepted.  On x86, there's no guarantee that
> the BIOS tables and run-time tables are the same, so customized and not
> customized may be very different, and these kernel changes would make sense.
> On ARMv8, the boot and run-time tables will be essentially identical most of
> the time so it's not clear there's a lot of value in adding more stuff to
> sysfs.  If I create this kernel code, though, it seems to me it would make
> sense to change acpidump so it does not use /dev/mem for any architecture, but
> always uses sysfs on all architectures -- do you agree?

IMO, we could do this better.
Users won't want to see the original BIOS tables.
So the BIOS tables needn't appear in the userspace unless required, thus we could export them via debugfs.

Or even better:
We could provide some ioctl or sysctl from kernel to allow acpidump to obtain what it want, for example:
1. Find RSDP
2. Validate and dump a table from any address (we need to support Load/LoadTable opcodes)

> 
> I'll take a look at doing this on the kernel side...

Thanks.

Best regards
-Lv

> 
> > Thanks and best regards
> > -Lv
> >
> >>
> >>>> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
> >>>> Sent: Thursday, June 04, 2015 8:43 AM
> >>>>
> >>>> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
> >>>> contents may or may not be valid depending on the memory map being used, since
> >>>> they are not standardized.
> >>>>
> >>>> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
> >>>> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
> >>>> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
> >>>> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
> >>>> that the tables retrieved are the ones actually being used and that their
> >>>> content is correct.
> >>>>
> >>>> This patch applies on top of the 20150515 version, and I have included it in
> >>>> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
> >>>> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
> >>>>
> >>>> Signed-off-by: Al Stone <ahs3(a)redhat.com>
> >>>>
> >>>> --
> >>>> ciao,
> >>>> al
> >>>> -----------------------------------
> >>>> Al Stone
> >>>> Software Engineer
> >>>> Red Hat, Inc.
> >>>> ahs3(a)redhat.com
> >>>> -----------------------------------
> >>
> >>
> >> --
> >> ciao,
> >> al
> >> -----------------------------------
> >> Al Stone
> >> Software Engineer
> >> Red Hat, Inc.
> >> ahs3(a)redhat.com
> >> -----------------------------------
> 
> 
> --
> ciao,
> al
> -----------------------------------
> Al Stone
> Software Engineer
> Red Hat, Inc.
> ahs3(a)redhat.com
> -----------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-16  0:33 Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2015-06-16  0:33 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 6330 bytes --]

Hi,

> From: Al Stone [mailto:ahs3(a)redhat.com]
> Sent: Tuesday, June 16, 2015 5:42 AM
> 
> On 06/14/2015 07:13 PM, Zheng, Lv wrote:
> > Hi,
> >
> >> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Zheng, Lv
> >> Sent: Monday, June 15, 2015 8:49 AM
> >>
> >> Hi,
> >>
> >>> From: Zheng, Lv
> >>> Sent: Monday, June 15, 2015 8:40 AM
> >>>
> >>> Hi,
> >>>
> >>>> From: Al Stone [mailto:ahs3(a)redhat.com]
> >>>> Sent: Saturday, June 13, 2015 6:00 AM
> >>>>
> >>>> On 06/09/2015 12:16 AM, Zheng, Lv wrote:
> >>>>> Hi,
> >>>>>
> >>>>> The patch is wrong.
> >>>>> If we want to dump tables without accessing /dev/mem, we have acpidump -c.
> >>>>> The only problem here is:
> >>>>> There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
> >>>>> So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.
> >>>>>
> >>>>> We've noticed the similar issue in handling this kernel bug:
> >>>>> https://bugzilla.kernel.org/show_bug.cgi?id=87971
> >>>>> The fix for this issue can be found here:
> >>>>> https://github.com/acpica/acpica/pull/77
> >>>>>
> >>>>> Thanks and best regards
> >>>>> -Lv
> >>>>
> >>>> The problem I have with this fix for the issue is that this command:
> >>>>
> >>>> 	# acpidump -n APIC
> >>>>
> >>>> will work on x86 but fail on arm64.  Getting the -c option to work properly
> >>>> is a good thing, and should be done regardless.  But, this means we have to
> >>>> use "acpidump -c -n APIC" on systems without /dev/mem.  For my part:
> >>>>
> >>>>    (a) these are not really customized tables, but the standard ACPI tables
> >>>>        used to boot the system, so using -c is a little confusing, and
> >>>>
> >>>>    (b) we now have to use different commands on different architectures to
> >>>>        get the same result.
> >>>>
> >>>> My preference would be that the same command has the same behavior everywhere,
> >>>> which is why I patched it the way I did.
> >>>
> >>> This is not our preference, though...
> >>> I've been in the trouble of being easily confused by the bug reporters.
> >>> And I cannot distinguish if the table has been customized or root cause the bugs if the reporter did what I asked for but hid what
> he
> >>> silently did.
> >>> If we cannot distinguish the BIOS provided tables and the user customized tables from users' output, we'll likely lose the capability
> of
> >>> taking evidence...
> >>>
> >>>>
> >>>> This happens to be very useful on arm64 where /dev/mem is not reliable, but it
> >>>> could also be usable on any system that does not want to expose /dev/mem for
> >>>> some reason.  I think the advantage of the patch sent is that the user command
> >>>> stays the same no matter what the situation.
> >>>
> >>> My suggestion would be to support this via kernel.
> >>> Let the kernel exposes 2 kind of tables (customized or not customized) into the /sys/firmware/acpi/tables.
> >>> Which can meet both of the requirements.
> >>
> >> Or we currently can make the "-c" mode the default behavior and add a new option for dumping the BIOS tables.
> >
> > And you can check if this commit is acceptable:
> > https://github.com/acpica/acpica/pull/80
> 
> Hrm.  I guess if we have to have the -c option, I would prefer the first patch
> where we just get rid of the dependence on /dev/mem.  I think it is easier to
> explain that -c must always be used rather than trying to explain how to use
> the -c on/off options.

We can switch this option back when the support is ready.

> 
> I think the path I would like to see long term is to split up /sys as you
> suggested so that there is a run-time version of the ACPI tables, and a copy
> of the tables from UEFI.  That way, no one has to rely on /dev/mem at all,
> and acpidump can go back to parameters operating exactly the same way on all
> possible platforms.

Removing the dependency of /dev/mem and exporting BIOS table via /sys or even better - making all acpidump functionalities a part of the kernel.
I think we need to add one more pointer in acpi_table_desc first.

Thanks and best regards
-Lv

> 
> > Thanks and best regards
> > -Lv
> >
> >>
> >> Thanks and best regards
> >> -Lv
> >>
> >>
> >>>
> >>> Thanks and best regards
> >>> -Lv
> >>>
> >>>>
> >>>>>> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
> >>>>>> Sent: Thursday, June 04, 2015 8:43 AM
> >>>>>>
> >>>>>> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
> >>>>>> contents may or may not be valid depending on the memory map being used, since
> >>>>>> they are not standardized.
> >>>>>>
> >>>>>> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
> >>>>>> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
> >>>>>> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
> >>>>>> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
> >>>>>> that the tables retrieved are the ones actually being used and that their
> >>>>>> content is correct.
> >>>>>>
> >>>>>> This patch applies on top of the 20150515 version, and I have included it in
> >>>>>> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
> >>>>>> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
> >>>>>>
> >>>>>> Signed-off-by: Al Stone <ahs3(a)redhat.com>
> >>>>>>
> >>>>>> --
> >>>>>> ciao,
> >>>>>> al
> >>>>>> -----------------------------------
> >>>>>> Al Stone
> >>>>>> Software Engineer
> >>>>>> Red Hat, Inc.
> >>>>>> ahs3(a)redhat.com
> >>>>>> -----------------------------------
> >>>>
> >>>>
> >>>> --
> >>>> ciao,
> >>>> al
> >>>> -----------------------------------
> >>>> Al Stone
> >>>> Software Engineer
> >>>> Red Hat, Inc.
> >>>> ahs3(a)redhat.com
> >>>> -----------------------------------
> >> _______________________________________________
> >> Devel mailing list
> >> Devel(a)acpica.org
> >> https://lists.acpica.org/mailman/listinfo/devel
> 
> 
> --
> ciao,
> al
> -----------------------------------
> Al Stone
> Software Engineer
> Red Hat, Inc.
> ahs3(a)redhat.com
> -----------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-15 21:36 Al Stone
  0 siblings, 0 replies; 10+ messages in thread
From: Al Stone @ 2015-06-15 21:36 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 6209 bytes --]

On 06/14/2015 06:39 PM, Zheng, Lv wrote:
> Hi, 
> 
>> From: Al Stone [mailto:ahs3(a)redhat.com]
>> Sent: Saturday, June 13, 2015 6:00 AM
>>
>> On 06/09/2015 12:16 AM, Zheng, Lv wrote:
>>> Hi,
>>>
>>> The patch is wrong.
>>> If we want to dump tables without accessing /dev/mem, we have acpidump -c.
>>> The only problem here is:
>>> There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
>>> So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.
>>>
>>> We've noticed the similar issue in handling this kernel bug:
>>> https://bugzilla.kernel.org/show_bug.cgi?id=87971
>>> The fix for this issue can be found here:
>>> https://github.com/acpica/acpica/pull/77
>>>
>>> Thanks and best regards
>>> -Lv
>>
>> The problem I have with this fix for the issue is that this command:
>>
>> 	# acpidump -n APIC
>>
>> will work on x86 but fail on arm64.  Getting the -c option to work properly
>> is a good thing, and should be done regardless.  But, this means we have to
>> use "acpidump -c -n APIC" on systems without /dev/mem.  For my part:
>>
>>    (a) these are not really customized tables, but the standard ACPI tables
>>        used to boot the system, so using -c is a little confusing, and
>>
>>    (b) we now have to use different commands on different architectures to
>>        get the same result.
>>
>> My preference would be that the same command has the same behavior everywhere,
>> which is why I patched it the way I did.
> 
> This is not our preference, though...
> I've been in the trouble of being easily confused by the bug reporters.
> And I cannot distinguish if the table has been customized or root cause the bugs if the reporter did what I asked for but hid what he silently did.
> If we cannot distinguish the BIOS provided tables and the user customized tables from users' output, we'll likely lose the capability of taking evidence...

Understood; I was in technical support roles for many years.

Perhaps I am misunderstanding this use of the word "customized."  On ARM, the
only way I can be sure to get the tables supplied by UEFI is to use the UEFI
shell and dump them.  Once the OS has booted, the tables in /sys/firmware/acpi
are what the system is currently using, and those are the ones I'm interested
in using for debugging when something breaks.  So, unless I have replaced the
DSDT in the initrd, or added SSDTs, /sys/firmware/acpi will be exactly the same
as what UEFI provided.  Even then, those are the tables I want to see if there
is a problem since those are the ones being used.  Is that what "customized"
means, in this case: the actual run-time tables and not the tables provided by
UEFI?

>> This happens to be very useful on arm64 where /dev/mem is not reliable, but it
>> could also be usable on any system that does not want to expose /dev/mem for
>> some reason.  I think the advantage of the patch sent is that the user command
>> stays the same no matter what the situation.
> 
> My suggestion would be to support this via kernel.
> Let the kernel exposes 2 kind of tables (customized or not customized) into the /sys/firmware/acpi/tables.
> Which can meet both of the requirements.

Okay, this sort of answers my questions.  "Customized" is not the word I would
have chosen for this -- I think I would have made it
/sys/firmware/acpi/tables/current (i.e., "customized") and
/sys/firmware/acpi/tables/boot (i.e.,
not "customized").  When I was thinking of tables as being customized, I was
thinking of new versions of all kinds of tables, not just the DSDT and SSDTs.
On ARM, going in and out of ACPI mode is just not allowed so there's really no
opportunity to customize the tables much, other than adding SSDTs.

Creating new sysfs entries in a kernel driver would be simple enough to do;
the issue would be getting it accepted.  On x86, there's no guarantee that
the BIOS tables and run-time tables are the same, so customized and not
customized may be very different, and these kernel changes would make sense.
On ARMv8, the boot and run-time tables will be essentially identical most of
the time so it's not clear there's a lot of value in adding more stuff to
sysfs.  If I create this kernel code, though, it seems to me it would make
sense to change acpidump so it does not use /dev/mem for any architecture, but
always uses sysfs on all architectures -- do you agree?

I'll take a look at doing this on the kernel side...

> Thanks and best regards
> -Lv
> 
>>
>>>> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
>>>> Sent: Thursday, June 04, 2015 8:43 AM
>>>>
>>>> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
>>>> contents may or may not be valid depending on the memory map being used, since
>>>> they are not standardized.
>>>>
>>>> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
>>>> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
>>>> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
>>>> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
>>>> that the tables retrieved are the ones actually being used and that their
>>>> content is correct.
>>>>
>>>> This patch applies on top of the 20150515 version, and I have included it in
>>>> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
>>>> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
>>>>
>>>> Signed-off-by: Al Stone <ahs3(a)redhat.com>
>>>>
>>>> --
>>>> ciao,
>>>> al
>>>> -----------------------------------
>>>> Al Stone
>>>> Software Engineer
>>>> Red Hat, Inc.
>>>> ahs3(a)redhat.com
>>>> -----------------------------------
>>
>>
>> --
>> ciao,
>> al
>> -----------------------------------
>> Al Stone
>> Software Engineer
>> Red Hat, Inc.
>> ahs3(a)redhat.com
>> -----------------------------------


-- 
ciao,
al
-----------------------------------
Al Stone
Software Engineer
Red Hat, Inc.
ahs3(a)redhat.com
-----------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-15  1:13 Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2015-06-15  1:13 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 4926 bytes --]

Hi,

> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Zheng, Lv
> Sent: Monday, June 15, 2015 8:49 AM
> 
> Hi,
> 
> > From: Zheng, Lv
> > Sent: Monday, June 15, 2015 8:40 AM
> >
> > Hi,
> >
> > > From: Al Stone [mailto:ahs3(a)redhat.com]
> > > Sent: Saturday, June 13, 2015 6:00 AM
> > >
> > > On 06/09/2015 12:16 AM, Zheng, Lv wrote:
> > > > Hi,
> > > >
> > > > The patch is wrong.
> > > > If we want to dump tables without accessing /dev/mem, we have acpidump -c.
> > > > The only problem here is:
> > > > There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
> > > > So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.
> > > >
> > > > We've noticed the similar issue in handling this kernel bug:
> > > > https://bugzilla.kernel.org/show_bug.cgi?id=87971
> > > > The fix for this issue can be found here:
> > > > https://github.com/acpica/acpica/pull/77
> > > >
> > > > Thanks and best regards
> > > > -Lv
> > >
> > > The problem I have with this fix for the issue is that this command:
> > >
> > > 	# acpidump -n APIC
> > >
> > > will work on x86 but fail on arm64.  Getting the -c option to work properly
> > > is a good thing, and should be done regardless.  But, this means we have to
> > > use "acpidump -c -n APIC" on systems without /dev/mem.  For my part:
> > >
> > >    (a) these are not really customized tables, but the standard ACPI tables
> > >        used to boot the system, so using -c is a little confusing, and
> > >
> > >    (b) we now have to use different commands on different architectures to
> > >        get the same result.
> > >
> > > My preference would be that the same command has the same behavior everywhere,
> > > which is why I patched it the way I did.
> >
> > This is not our preference, though...
> > I've been in the trouble of being easily confused by the bug reporters.
> > And I cannot distinguish if the table has been customized or root cause the bugs if the reporter did what I asked for but hid what he
> > silently did.
> > If we cannot distinguish the BIOS provided tables and the user customized tables from users' output, we'll likely lose the capability of
> > taking evidence...
> >
> > >
> > > This happens to be very useful on arm64 where /dev/mem is not reliable, but it
> > > could also be usable on any system that does not want to expose /dev/mem for
> > > some reason.  I think the advantage of the patch sent is that the user command
> > > stays the same no matter what the situation.
> >
> > My suggestion would be to support this via kernel.
> > Let the kernel exposes 2 kind of tables (customized or not customized) into the /sys/firmware/acpi/tables.
> > Which can meet both of the requirements.
> 
> Or we currently can make the "-c" mode the default behavior and add a new option for dumping the BIOS tables.

And you can check if this commit is acceptable:
https://github.com/acpica/acpica/pull/80

Thanks and best regards
-Lv

> 
> Thanks and best regards
> -Lv
> 
> 
> >
> > Thanks and best regards
> > -Lv
> >
> > >
> > > >> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
> > > >> Sent: Thursday, June 04, 2015 8:43 AM
> > > >>
> > > >> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
> > > >> contents may or may not be valid depending on the memory map being used, since
> > > >> they are not standardized.
> > > >>
> > > >> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
> > > >> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
> > > >> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
> > > >> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
> > > >> that the tables retrieved are the ones actually being used and that their
> > > >> content is correct.
> > > >>
> > > >> This patch applies on top of the 20150515 version, and I have included it in
> > > >> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
> > > >> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
> > > >>
> > > >> Signed-off-by: Al Stone <ahs3(a)redhat.com>
> > > >>
> > > >> --
> > > >> ciao,
> > > >> al
> > > >> -----------------------------------
> > > >> Al Stone
> > > >> Software Engineer
> > > >> Red Hat, Inc.
> > > >> ahs3(a)redhat.com
> > > >> -----------------------------------
> > >
> > >
> > > --
> > > ciao,
> > > al
> > > -----------------------------------
> > > Al Stone
> > > Software Engineer
> > > Red Hat, Inc.
> > > ahs3(a)redhat.com
> > > -----------------------------------
> _______________________________________________
> Devel mailing list
> Devel(a)acpica.org
> https://lists.acpica.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-15  0:48 Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2015-06-15  0:48 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 4420 bytes --]

Hi,

> From: Zheng, Lv
> Sent: Monday, June 15, 2015 8:40 AM
> To: 'Al Stone'; devel(a)acpica.org
> Subject: RE: [Devel] [PATCH] handle Linux systems without /dev/mem
> 
> Hi,
> 
> > From: Al Stone [mailto:ahs3(a)redhat.com]
> > Sent: Saturday, June 13, 2015 6:00 AM
> >
> > On 06/09/2015 12:16 AM, Zheng, Lv wrote:
> > > Hi,
> > >
> > > The patch is wrong.
> > > If we want to dump tables without accessing /dev/mem, we have acpidump -c.
> > > The only problem here is:
> > > There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
> > > So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.
> > >
> > > We've noticed the similar issue in handling this kernel bug:
> > > https://bugzilla.kernel.org/show_bug.cgi?id=87971
> > > The fix for this issue can be found here:
> > > https://github.com/acpica/acpica/pull/77
> > >
> > > Thanks and best regards
> > > -Lv
> >
> > The problem I have with this fix for the issue is that this command:
> >
> > 	# acpidump -n APIC
> >
> > will work on x86 but fail on arm64.  Getting the -c option to work properly
> > is a good thing, and should be done regardless.  But, this means we have to
> > use "acpidump -c -n APIC" on systems without /dev/mem.  For my part:
> >
> >    (a) these are not really customized tables, but the standard ACPI tables
> >        used to boot the system, so using -c is a little confusing, and
> >
> >    (b) we now have to use different commands on different architectures to
> >        get the same result.
> >
> > My preference would be that the same command has the same behavior everywhere,
> > which is why I patched it the way I did.
> 
> This is not our preference, though...
> I've been in the trouble of being easily confused by the bug reporters.
> And I cannot distinguish if the table has been customized or root cause the bugs if the reporter did what I asked for but hid what he
> silently did.
> If we cannot distinguish the BIOS provided tables and the user customized tables from users' output, we'll likely lose the capability of
> taking evidence...
> 
> >
> > This happens to be very useful on arm64 where /dev/mem is not reliable, but it
> > could also be usable on any system that does not want to expose /dev/mem for
> > some reason.  I think the advantage of the patch sent is that the user command
> > stays the same no matter what the situation.
> 
> My suggestion would be to support this via kernel.
> Let the kernel exposes 2 kind of tables (customized or not customized) into the /sys/firmware/acpi/tables.
> Which can meet both of the requirements.

Or we currently can make the "-c" mode the default behavior and add a new option for dumping the BIOS tables.

Thanks and best regards
-Lv


> 
> Thanks and best regards
> -Lv
> 
> >
> > >> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
> > >> Sent: Thursday, June 04, 2015 8:43 AM
> > >>
> > >> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
> > >> contents may or may not be valid depending on the memory map being used, since
> > >> they are not standardized.
> > >>
> > >> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
> > >> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
> > >> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
> > >> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
> > >> that the tables retrieved are the ones actually being used and that their
> > >> content is correct.
> > >>
> > >> This patch applies on top of the 20150515 version, and I have included it in
> > >> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
> > >> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
> > >>
> > >> Signed-off-by: Al Stone <ahs3(a)redhat.com>
> > >>
> > >> --
> > >> ciao,
> > >> al
> > >> -----------------------------------
> > >> Al Stone
> > >> Software Engineer
> > >> Red Hat, Inc.
> > >> ahs3(a)redhat.com
> > >> -----------------------------------
> >
> >
> > --
> > ciao,
> > al
> > -----------------------------------
> > Al Stone
> > Software Engineer
> > Red Hat, Inc.
> > ahs3(a)redhat.com
> > -----------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-15  0:39 Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2015-06-15  0:39 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 3904 bytes --]

Hi, 

> From: Al Stone [mailto:ahs3(a)redhat.com]
> Sent: Saturday, June 13, 2015 6:00 AM
> 
> On 06/09/2015 12:16 AM, Zheng, Lv wrote:
> > Hi,
> >
> > The patch is wrong.
> > If we want to dump tables without accessing /dev/mem, we have acpidump -c.
> > The only problem here is:
> > There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
> > So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.
> >
> > We've noticed the similar issue in handling this kernel bug:
> > https://bugzilla.kernel.org/show_bug.cgi?id=87971
> > The fix for this issue can be found here:
> > https://github.com/acpica/acpica/pull/77
> >
> > Thanks and best regards
> > -Lv
> 
> The problem I have with this fix for the issue is that this command:
> 
> 	# acpidump -n APIC
> 
> will work on x86 but fail on arm64.  Getting the -c option to work properly
> is a good thing, and should be done regardless.  But, this means we have to
> use "acpidump -c -n APIC" on systems without /dev/mem.  For my part:
> 
>    (a) these are not really customized tables, but the standard ACPI tables
>        used to boot the system, so using -c is a little confusing, and
> 
>    (b) we now have to use different commands on different architectures to
>        get the same result.
> 
> My preference would be that the same command has the same behavior everywhere,
> which is why I patched it the way I did.

This is not our preference, though...
I've been in the trouble of being easily confused by the bug reporters.
And I cannot distinguish if the table has been customized or root cause the bugs if the reporter did what I asked for but hid what he silently did.
If we cannot distinguish the BIOS provided tables and the user customized tables from users' output, we'll likely lose the capability of taking evidence...

> 
> This happens to be very useful on arm64 where /dev/mem is not reliable, but it
> could also be usable on any system that does not want to expose /dev/mem for
> some reason.  I think the advantage of the patch sent is that the user command
> stays the same no matter what the situation.

My suggestion would be to support this via kernel.
Let the kernel exposes 2 kind of tables (customized or not customized) into the /sys/firmware/acpi/tables.
Which can meet both of the requirements.

Thanks and best regards
-Lv

> 
> >> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
> >> Sent: Thursday, June 04, 2015 8:43 AM
> >>
> >> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
> >> contents may or may not be valid depending on the memory map being used, since
> >> they are not standardized.
> >>
> >> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
> >> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
> >> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
> >> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
> >> that the tables retrieved are the ones actually being used and that their
> >> content is correct.
> >>
> >> This patch applies on top of the 20150515 version, and I have included it in
> >> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
> >> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
> >>
> >> Signed-off-by: Al Stone <ahs3(a)redhat.com>
> >>
> >> --
> >> ciao,
> >> al
> >> -----------------------------------
> >> Al Stone
> >> Software Engineer
> >> Red Hat, Inc.
> >> ahs3(a)redhat.com
> >> -----------------------------------
> 
> 
> --
> ciao,
> al
> -----------------------------------
> Al Stone
> Software Engineer
> Red Hat, Inc.
> ahs3(a)redhat.com
> -----------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-12 22:00 Al Stone
  0 siblings, 0 replies; 10+ messages in thread
From: Al Stone @ 2015-06-12 22:00 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 2992 bytes --]

On 06/09/2015 12:16 AM, Zheng, Lv wrote:
> Hi,
> 
> The patch is wrong.
> If we want to dump tables without accessing /dev/mem, we have acpidump -c.
> The only problem here is:
> There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
> So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.
> 
> We've noticed the similar issue in handling this kernel bug:
> https://bugzilla.kernel.org/show_bug.cgi?id=87971
> The fix for this issue can be found here:
> https://github.com/acpica/acpica/pull/77
> 
> Thanks and best regards
> -Lv

The problem I have with this fix for the issue is that this command:

	# acpidump -n APIC

will work on x86 but fail on arm64.  Getting the -c option to work properly
is a good thing, and should be done regardless.  But, this means we have to
use "acpidump -c -n APIC" on systems without /dev/mem.  For my part:

   (a) these are not really customized tables, but the standard ACPI tables
       used to boot the system, so using -c is a little confusing, and

   (b) we now have to use different commands on different architectures to
       get the same result.

My preference would be that the same command has the same behavior everywhere,
which is why I patched it the way I did.

This happens to be very useful on arm64 where /dev/mem is not reliable, but it
could also be usable on any system that does not want to expose /dev/mem for
some reason.  I think the advantage of the patch sent is that the user command
stays the same no matter what the situation.

>> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
>> Sent: Thursday, June 04, 2015 8:43 AM
>>
>> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
>> contents may or may not be valid depending on the memory map being used, since
>> they are not standardized.
>>
>> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
>> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
>> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
>> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
>> that the tables retrieved are the ones actually being used and that their
>> content is correct.
>>
>> This patch applies on top of the 20150515 version, and I have included it in
>> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
>> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
>>
>> Signed-off-by: Al Stone <ahs3(a)redhat.com>
>>
>> --
>> ciao,
>> al
>> -----------------------------------
>> Al Stone
>> Software Engineer
>> Red Hat, Inc.
>> ahs3(a)redhat.com
>> -----------------------------------


-- 
ciao,
al
-----------------------------------
Al Stone
Software Engineer
Red Hat, Inc.
ahs3(a)redhat.com
-----------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-09  6:16 Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2015-06-09  6:16 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1750 bytes --]

Hi,

The patch is wrong.
If we want to dump tables without accessing /dev/mem, we have acpidump -c.
The only problem here is:
There is a bug that even with -c specified, acpidump cannot work without accessing /dev/mem.
So we shouldn't introduce a new portable acpidump OSL but should fix the very problem.

We've noticed the similar issue in handling this kernel bug:
https://bugzilla.kernel.org/show_bug.cgi?id=87971
The fix for this issue can be found here:
https://github.com/acpica/acpica/pull/77

Thanks and best regards
-Lv

> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Al Stone
> Sent: Thursday, June 04, 2015 8:43 AM
> 
> On arm64 systems in particular, the use of /dev/mem is not recommended.  The
> contents may or may not be valid depending on the memory map being used, since
> they are not standardized.
> 
> The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
> use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
> (a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
> tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
> that the tables retrieved are the ones actually being used and that their
> content is correct.
> 
> This patch applies on top of the 20150515 version, and I have included it in
> the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
> resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.
> 
> Signed-off-by: Al Stone <ahs3(a)redhat.com>
> 
> --
> ciao,
> al
> -----------------------------------
> Al Stone
> Software Engineer
> Red Hat, Inc.
> ahs3(a)redhat.com
> -----------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Devel] [PATCH] handle Linux systems without /dev/mem
@ 2015-06-04  0:43 Al Stone
  0 siblings, 0 replies; 10+ messages in thread
From: Al Stone @ 2015-06-04  0:43 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]

On arm64 systems in particular, the use of /dev/mem is not recommended.  The
contents may or may not be valid depending on the memory map being used, since
they are not standardized.

The attached patch will cause arm64 (aka ARMv8 or AArch64) Linux systems to
use a new file called source/os_specific/service_layers/oslinuxtbl_nodevmem.c
(a subset of the oslinuxtbl.c code) that allows acpidump to read all ACPI
tables from /sys/firmware/acpi instead of from /dev/mem.  This will help ensure
that the tables retrieved are the ones actually being used and that their
content is correct.

This patch applies on top of the 20150515 version, and I have included it in
the 20150515-2 versions of the Fedora and Debian packages.  I've tried the
resulting acpidump on x86, x86_64 and arm64 systems and it seems to work well.

Signed-off-by: Al Stone <ahs3(a)redhat.com>

-- 
ciao,
al
-----------------------------------
Al Stone
Software Engineer
Red Hat, Inc.
ahs3(a)redhat.com
-----------------------------------

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nodevmem.patch --]
[-- Type: text/x-patch, Size: 21996 bytes --]

diff -Naur acpica-unix2-20150515/generate/unix/acpidump/Makefile acpica-unix2-20150515.devmem/generate/unix/acpidump/Makefile
--- acpica-unix2-20150515/generate/unix/acpidump/Makefile	2015-05-15 17:49:17.000000000 -0600
+++ acpica-unix2-20150515.devmem/generate/unix/acpidump/Makefile	2015-06-02 15:00:31.813746336 -0600
@@ -67,10 +67,17 @@
 OBJECTS += \
 	$(OBJDIR)/osbsdtbl.o
 else
+
+ifeq ($(NO_DEV_MEM), true)
+OBJECTS += \
+	$(OBJDIR)/oslinuxtbl_nodevmem.o
+else
 OBJECTS += \
 	$(OBJDIR)/oslinuxtbl.o
 endif
 
+endif
+
 #
 # Flags specific to acpidump
 #
diff -Naur acpica-unix2-20150515/generate/unix/Makefile.config acpica-unix2-20150515.devmem/generate/unix/Makefile.config
--- acpica-unix2-20150515/generate/unix/Makefile.config	2015-06-03 14:57:30.328724317 -0600
+++ acpica-unix2-20150515.devmem/generate/unix/Makefile.config	2015-06-02 15:03:53.727560100 -0600
@@ -49,6 +49,7 @@
 LINKPROG =   $(CC) $(OBJECTS) -o $(PROG) $(LDFLAGS) $(OPT_LDFLAGS)
 PREFIX ?=    /usr
 INSTALLDIR = $(PREFIX)/bin
+UNAME_M := $(shell uname -m)
 UNAME_S := $(shell uname -s)
 
 #
@@ -70,6 +71,12 @@
 HOST =       _NetBSD
 endif
 
+ifeq ($(UNAME_S), Linux)
+ifeq ($(UNAME_M), aarch64)
+NO_DEV_MEM ?= true
+endif
+endif
+
 ifeq ($(HOST), _APPLE)
 INSTALL  =   cp
 INSTALLFLAGS ?= -f
diff -Naur acpica-unix2-20150515/source/os_specific/service_layers/oslinuxtbl_nodevmem.c acpica-unix2-20150515.devmem/source/os_specific/service_layers/oslinuxtbl_nodevmem.c
--- acpica-unix2-20150515/source/os_specific/service_layers/oslinuxtbl_nodevmem.c	1969-12-31 17:00:00.000000000 -0700
+++ acpica-unix2-20150515.devmem/source/os_specific/service_layers/oslinuxtbl_nodevmem.c	2015-06-02 16:14:38.088031027 -0600
@@ -0,0 +1,734 @@
+/******************************************************************************
+ *
+ * Module Name: oslinuxtbl_nodevmem - Linux OSL for obtaining ACPI tables
+ *                                    that assumes you cannot use /dev/mem
+ *
+ *****************************************************************************/
+
+#include "acpidump.h"
+
+
+#define _COMPONENT          ACPI_OS_SERVICES
+        ACPI_MODULE_NAME    ("oslinuxtbl_nodevmem")
+
+
+#ifndef PATH_MAX
+#define PATH_MAX 256
+#endif
+
+
+/* List of information about obtained ACPI tables */
+
+typedef struct osl_table_info
+{
+    struct osl_table_info   *Next;
+    UINT32                  Instance;
+    char                    Signature[ACPI_NAME_SIZE];
+
+} OSL_TABLE_INFO;
+
+/* Local prototypes */
+
+static ACPI_STATUS
+OslTableInitialize (
+    void);
+
+static ACPI_STATUS
+OslTableNameFromFile (
+    char                    *Filename,
+    char                    *Signature,
+    UINT32                  *Instance);
+
+static ACPI_STATUS
+OslAddTableToList (
+    char                    *Signature,
+    UINT32                  Instance);
+
+static ACPI_STATUS
+OslReadTableFromFile (
+    char                    *Filename,
+    ACPI_SIZE               FileOffset,
+    char                    *Signature,
+    ACPI_TABLE_HEADER       **Table);
+
+static ACPI_STATUS
+OslListAcpiTables (
+    char                    *Directory);
+
+static ACPI_STATUS
+OslGetAcpiTable (
+    char                    *Pathname,
+    char                    *Signature,
+    UINT32                  Instance,
+    ACPI_TABLE_HEADER       **Table,
+    ACPI_PHYSICAL_ADDRESS   *Address);
+
+static ACPI_STATUS
+OslGetLastStatus (
+    ACPI_STATUS             DefaultStatus);
+
+
+/* File locations */
+
+#define DYNAMIC_TABLE_DIR   "/sys/firmware/acpi/tables/dynamic"
+#define STATIC_TABLE_DIR    "/sys/firmware/acpi/tables"
+
+/* Should we get dynamically loaded SSDTs from DYNAMIC_TABLE_DIR? */
+
+UINT8                   Gbl_DumpDynamicTables = TRUE;
+
+/* Initialization flags */
+
+UINT8                   Gbl_TableListInitialized = FALSE;
+
+/* Revision of RSD PTR */
+
+UINT8                   Gbl_Revision = 0;
+
+OSL_TABLE_INFO          *Gbl_TableListHead = NULL;
+UINT32                  Gbl_TableCount = 0;
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    OslGetLastStatus
+ *
+ * PARAMETERS:  DefaultStatus   - Default error status to return
+ *
+ * RETURN:      Status; Converted from errno.
+ *
+ * DESCRIPTION: Get last errno and conver it to ACPI_STATUS.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+OslGetLastStatus (
+    ACPI_STATUS             DefaultStatus)
+{
+
+    switch (errno)
+    {
+    case EACCES:
+    case EPERM:
+
+        return (AE_ACCESS);
+
+    case ENOENT:
+
+        return (AE_NOT_FOUND);
+
+    case ENOMEM:
+
+        return (AE_NO_MEMORY);
+
+    default:
+
+        return (DefaultStatus);
+    }
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiOsGetTableByAddress
+ *
+ * PARAMETERS:  Address         - Physical address of the ACPI table
+ *              Table           - Where a pointer to the table is returned
+ *
+ * RETURN:      Status; Table buffer is returned if AE_OK.
+ *              AE_NOT_FOUND: A valid table was not found at the address
+ *
+ * DESCRIPTION: Get an ACPI table via a physical memory address.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsGetTableByAddress (
+    ACPI_PHYSICAL_ADDRESS   Address,
+    ACPI_TABLE_HEADER       **Table)
+{
+    /*
+     * If this source file is being used, there is no reliable access
+     * to /dev/mem on this system.  Hence, we cannot retrieve a table
+     * by address at all and will always return AE_NOT_FOUND.
+     */
+
+    return AE_NOT_FOUND;
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiOsGetTableByName
+ *
+ * PARAMETERS:  Signature       - ACPI Signature for desired table. Must be
+ *                                a null terminated 4-character string.
+ *              Instance        - Multiple table support for SSDT/UEFI (0...n)
+ *                                Must be 0 for other tables.
+ *              Table           - Where a pointer to the table is returned
+ *              Address         - Where the table physical address is returned
+ *
+ * RETURN:      Status; Table buffer and physical address returned if AE_OK.
+ *              AE_LIMIT: Instance is beyond valid limit
+ *              AE_NOT_FOUND: A table with the signature was not found
+ *
+ * NOTE:        Assumes the input signature is uppercase.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsGetTableByName (
+    char                    *Signature,
+    UINT32                  Instance,
+    ACPI_TABLE_HEADER       **Table,
+    ACPI_PHYSICAL_ADDRESS   *Address)
+{
+    ACPI_STATUS             Status;
+
+
+    /* Get main ACPI tables from memory on first invocation of this function */
+
+    Status = OslTableInitialize ();
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    /* Attempt to get the table from the static directory */
+
+    Status = OslGetAcpiTable (STATIC_TABLE_DIR, Signature,
+        Instance, Table, Address);
+
+    if (ACPI_FAILURE (Status) && Status == AE_LIMIT)
+    {
+        if (Gbl_DumpDynamicTables)
+        {
+            /* Attempt to get a dynamic table */
+
+            Status = OslGetAcpiTable (DYNAMIC_TABLE_DIR, Signature,
+                Instance, Table, Address);
+        }
+    }
+
+    return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    OslAddTableToList
+ *
+ * PARAMETERS:  Signature       - Table signature
+ *              Instance        - Table instance
+ *
+ * RETURN:      Status; Successfully added if AE_OK.
+ *              AE_NO_MEMORY: Memory allocation error
+ *
+ * DESCRIPTION: Insert a table structure into OSL table list.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+OslAddTableToList (
+    char                    *Signature,
+    UINT32                  Instance)
+{
+    OSL_TABLE_INFO          *NewInfo;
+    OSL_TABLE_INFO          *Next;
+    UINT32                  NextInstance = 0;
+    BOOLEAN                 Found = FALSE;
+
+
+    NewInfo = calloc (1, sizeof (OSL_TABLE_INFO));
+    if (!NewInfo)
+    {
+        return (AE_NO_MEMORY);
+    }
+
+    ACPI_MOVE_NAME (NewInfo->Signature, Signature);
+
+    if (!Gbl_TableListHead)
+    {
+        Gbl_TableListHead = NewInfo;
+    }
+    else
+    {
+        Next = Gbl_TableListHead;
+        while (1)
+        {
+            if (ACPI_COMPARE_NAME (Next->Signature, Signature))
+            {
+                if (Next->Instance == Instance)
+                {
+                    Found = TRUE;
+                }
+                if (Next->Instance >= NextInstance)
+                {
+                    NextInstance = Next->Instance + 1;
+                }
+            }
+
+            if (!Next->Next)
+            {
+                break;
+            }
+            Next = Next->Next;
+        }
+        Next->Next = NewInfo;
+    }
+
+    if (Found)
+    {
+        if (Instance)
+        {
+            fprintf (stderr,
+                "%4.4s: Warning unmatched table instance %d, expected %d\n",
+                Signature, Instance, NextInstance);
+        }
+        Instance = NextInstance;
+    }
+
+    NewInfo->Instance = Instance;
+    Gbl_TableCount++;
+
+    return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiOsGetTableByIndex
+ *
+ * PARAMETERS:  Index           - Which table to get
+ *              Table           - Where a pointer to the table is returned
+ *              Instance        - Where a pointer to the table instance no. is
+ *                                returned
+ *              Address         - Where the table physical address is returned
+ *
+ * RETURN:      Status; Table buffer and physical address returned if AE_OK.
+ *              AE_LIMIT: Index is beyond valid limit
+ *
+ * DESCRIPTION: Get an ACPI table via an index value (0 through n). Returns
+ *              AE_LIMIT when an invalid index is reached. Index is not
+ *              necessarily an index into the RSDT/XSDT.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsGetTableByIndex (
+    UINT32                  Index,
+    ACPI_TABLE_HEADER       **Table,
+    UINT32                  *Instance,
+    ACPI_PHYSICAL_ADDRESS   *Address)
+{
+    OSL_TABLE_INFO          *Info;
+    ACPI_STATUS             Status;
+    UINT32                  i;
+
+
+    /* Get main ACPI tables from memory on first invocation of this function */
+
+    Status = OslTableInitialize ();
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    /* Validate Index */
+
+    if (Index >= Gbl_TableCount)
+    {
+        return (AE_LIMIT);
+    }
+
+    /* Point to the table list entry specified by the Index argument */
+
+    Info = Gbl_TableListHead;
+    for (i = 0; i < Index; i++)
+    {
+        Info = Info->Next;
+    }
+
+    /* Now we can just get the table via the signature */
+
+    Status = AcpiOsGetTableByName (Info->Signature, Info->Instance,
+        Table, Address);
+
+    if (ACPI_SUCCESS (Status))
+    {
+        *Instance = Info->Instance;
+    }
+    return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    OslTableInitialize
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Initialize ACPI table data. Get and store main ACPI tables to
+ *              local variables. Main ACPI tables include RSDT, FADT, RSDT,
+ *              and/or XSDT.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+OslTableInitialize (
+    void)
+{
+    ACPI_STATUS             Status;
+
+    if (Gbl_TableListInitialized)
+    {
+        return (AE_OK);
+    }
+
+    /* Add all tables found in the static directory */
+
+    Status = OslListAcpiTables (STATIC_TABLE_DIR);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    if (Gbl_DumpDynamicTables)
+    {
+        /* Add all dynamically loaded tables in the dynamic directory */
+
+        Status = OslListAcpiTables (DYNAMIC_TABLE_DIR);
+        if (ACPI_FAILURE (Status))
+        {
+            return (Status);
+        }
+    }
+
+    Gbl_TableListInitialized = TRUE;
+    return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    OslListAcpiTables
+ *
+ * PARAMETERS:  Directory           - Directory that contains the tables
+ *
+ * RETURN:      Status; Table list is initialized if AE_OK.
+ *
+ * DESCRIPTION: Add ACPI tables to the table list from a directory.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+OslListAcpiTables (
+    char                    *Directory)
+{
+    void                    *TableDir;
+    UINT32                  Instance;
+    char                    TempName[ACPI_NAME_SIZE];
+    char                    *Filename;
+    ACPI_STATUS             Status = AE_OK;
+
+
+    /* Open the requested directory */
+
+    TableDir = AcpiOsOpenDirectory (Directory, "*", REQUEST_FILE_ONLY);
+    if (!TableDir)
+    {
+        return (OslGetLastStatus (AE_NOT_FOUND));
+    }
+
+    /* Examine all entries in this directory */
+
+    while ((Filename = AcpiOsGetNextFilename (TableDir)))
+    {
+        /* Extract table name and instance number */
+
+        Status = OslTableNameFromFile (Filename, TempName, &Instance);
+
+        /* Ignore meaningless files */
+
+        if (ACPI_FAILURE (Status))
+        {
+            continue;
+        }
+
+        /* Add new info node to global table list */
+
+        Status = OslAddTableToList (TempName, Instance);
+        if (ACPI_FAILURE (Status))
+        {
+            break;
+        }
+    }
+
+    AcpiOsCloseDirectory (TableDir);
+    return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    OslTableNameFromFile
+ *
+ * PARAMETERS:  Filename            - File that contains the desired table
+ *              Signature           - Pointer to 4-character buffer to store
+ *                                    extracted table signature.
+ *              Instance            - Pointer to integer to store extracted
+ *                                    table instance number.
+ *
+ * RETURN:      Status; Table name is extracted if AE_OK.
+ *
+ * DESCRIPTION: Extract table signature and instance number from a table file
+ *              name.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+OslTableNameFromFile (
+    char                    *Filename,
+    char                    *Signature,
+    UINT32                  *Instance)
+{
+
+    /* Ignore meaningless files */
+
+    if (strlen (Filename) < ACPI_NAME_SIZE)
+    {
+        return (AE_BAD_SIGNATURE);
+    }
+
+    /* Extract instance number */
+
+    if (isdigit ((int) Filename[ACPI_NAME_SIZE]))
+    {
+        sscanf (&Filename[ACPI_NAME_SIZE], "%u", Instance);
+    }
+    else if (strlen (Filename) != ACPI_NAME_SIZE)
+    {
+        return (AE_BAD_SIGNATURE);
+    }
+    else
+    {
+        *Instance = 0;
+    }
+
+    /* Extract signature */
+
+    ACPI_MOVE_NAME (Signature, Filename);
+    return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    OslReadTableFromFile
+ *
+ * PARAMETERS:  Filename            - File that contains the desired table
+ *              FileOffset          - Offset of the table in file
+ *              Signature           - Optional ACPI Signature for desired table.
+ *                                    A null terminated 4-character string.
+ *              Table               - Where a pointer to the table is returned
+ *
+ * RETURN:      Status; Table buffer is returned if AE_OK.
+ *
+ * DESCRIPTION: Read a ACPI table from a file.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+OslReadTableFromFile (
+    char                    *Filename,
+    ACPI_SIZE               FileOffset,
+    char                    *Signature,
+    ACPI_TABLE_HEADER       **Table)
+{
+    FILE                    *TableFile;
+    ACPI_TABLE_HEADER       Header;
+    ACPI_TABLE_HEADER       *LocalTable = NULL;
+    UINT32                  TableLength;
+    INT32                   Count;
+    ACPI_STATUS             Status = AE_OK;
+
+
+    /* Open the file */
+
+    TableFile = fopen (Filename, "rb");
+    if (TableFile == NULL)
+    {
+        fprintf (stderr, "Could not open table file: %s\n", Filename);
+        return (OslGetLastStatus (AE_NOT_FOUND));
+    }
+
+    fseek (TableFile, FileOffset, SEEK_SET);
+
+    /* Read the Table header to get the table length */
+
+    Count = fread (&Header, 1, sizeof (ACPI_TABLE_HEADER), TableFile);
+    if (Count != sizeof (ACPI_TABLE_HEADER))
+    {
+        fprintf (stderr, "Could not read table header: %s\n", Filename);
+        Status = AE_BAD_HEADER;
+        goto Exit;
+    }
+
+    /* If signature is specified, it must match the table */
+
+    if (Signature)
+    {
+        if (ACPI_VALIDATE_RSDP_SIG (Signature))
+        {
+            if (!ACPI_VALIDATE_RSDP_SIG (Header.Signature)) {
+                fprintf (stderr, "Incorrect RSDP signature: found %8.8s\n",
+                    Header.Signature);
+                Status = AE_BAD_SIGNATURE;
+                goto Exit;
+            }
+        }
+        else if (!ACPI_COMPARE_NAME (Signature, Header.Signature))
+        {
+            fprintf (stderr, "Incorrect signature: Expecting %4.4s, found %4.4s\n",
+                Signature, Header.Signature);
+            Status = AE_BAD_SIGNATURE;
+            goto Exit;
+        }
+    }
+
+    TableLength = ApGetTableLength (&Header);
+    if (TableLength == 0)
+    {
+        Status = AE_BAD_HEADER;
+        goto Exit;
+    }
+
+    /* Read the entire table into a local buffer */
+
+    LocalTable = calloc (1, TableLength);
+    if (!LocalTable)
+    {
+        fprintf (stderr,
+            "%4.4s: Could not allocate buffer for table of length %X\n",
+            Header.Signature, TableLength);
+        Status = AE_NO_MEMORY;
+        goto Exit;
+    }
+
+    fseek (TableFile, FileOffset, SEEK_SET);
+
+    Count = fread (LocalTable, 1, TableLength, TableFile);
+    if (Count != TableLength)
+    {
+        fprintf (stderr, "%4.4s: Could not read table content\n",
+            Header.Signature);
+        Status = AE_INVALID_TABLE_LENGTH;
+        goto Exit;
+    }
+
+    /* Validate checksum */
+
+    (void) ApIsValidChecksum (LocalTable);
+
+Exit:
+    fclose (TableFile);
+    *Table = LocalTable;
+    return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    OslGetAcpiTable
+ *
+ * PARAMETERS:  Pathname        - Directory to find Linux ACPI table
+ *              Signature       - ACPI Signature for desired table. Must be
+ *                                a null terminated 4-character string.
+ *              Instance        - Multiple table support for SSDT/UEFI (0...n)
+ *                                Must be 0 for other tables.
+ *              Table           - Where a pointer to the table is returned
+ *              Address         - Where the table physical address is returned
+ *
+ * RETURN:      Status; Table buffer is returned if AE_OK.
+ *              AE_LIMIT: Instance is beyond valid limit
+ *              AE_NOT_FOUND: A table with the signature was not found
+ *
+ * DESCRIPTION: Get an OS ACPI table.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+OslGetAcpiTable (
+    char                    *Pathname,
+    char                    *Signature,
+    UINT32                  Instance,
+    ACPI_TABLE_HEADER       **Table,
+    ACPI_PHYSICAL_ADDRESS   *Address)
+{
+    void                    *TableDir;
+    UINT32                  CurrentInstance = 0;
+    char                    TempName[ACPI_NAME_SIZE];
+    char                    TableFilename[PATH_MAX];
+    char                    *Filename;
+    ACPI_STATUS             Status;
+
+
+    /* Open the directory for ACPI tables */
+
+    TableDir = AcpiOsOpenDirectory (Pathname, "*", REQUEST_FILE_ONLY);
+    if (!TableDir)
+    {
+        return (OslGetLastStatus (AE_NOT_FOUND));
+    }
+
+    /* Attempt to find the table in the directory */
+
+    while ((Filename = AcpiOsGetNextFilename (TableDir)))
+    {
+        /* Ignore meaningless files */
+
+        if (!ACPI_COMPARE_NAME (Filename, Signature))
+        {
+            continue;
+        }
+
+        /* Extract table name and instance number */
+
+        Status = OslTableNameFromFile (Filename, TempName, &CurrentInstance);
+
+        /* Ignore meaningless files */
+
+        if (ACPI_FAILURE (Status) || CurrentInstance != Instance)
+        {
+            continue;
+        }
+
+        /* Create the table pathname */
+
+        if (Instance != 0)
+        {
+            sprintf (TableFilename, "%s/%4.4s%d", Pathname, TempName, Instance);
+        }
+        else
+        {
+            sprintf (TableFilename, "%s/%4.4s", Pathname, TempName);
+        }
+        break;
+    }
+
+    AcpiOsCloseDirectory (TableDir);
+
+    if (!Filename)
+    {
+        return (AE_LIMIT);
+    }
+
+    /* There is no physical address saved for ACPI tables, use zero */
+
+    *Address = 0;
+    Status = OslReadTableFromFile (TableFilename, 0, NULL, Table);
+
+    return (Status);
+}

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-06-16  0:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15 21:42 [Devel] [PATCH] handle Linux systems without /dev/mem Al Stone
  -- strict thread matches above, loose matches on Subject: below --
2015-06-16  0:41 Zheng, Lv
2015-06-16  0:33 Zheng, Lv
2015-06-15 21:36 Al Stone
2015-06-15  1:13 Zheng, Lv
2015-06-15  0:48 Zheng, Lv
2015-06-15  0:39 Zheng, Lv
2015-06-12 22:00 Al Stone
2015-06-09  6:16 Zheng, Lv
2015-06-04  0:43 Al Stone

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.