lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 10 Mar 2015 07:26:03 +0800
From:	"Li, Aubrey" <aubrey.li@...ux.intel.com>
To:	Ingo Molnar <mingo@...nel.org>
CC:	Arjan van de Ven <arjan@...ux.intel.com>,
	Borislav Petkov <bp@...en8.de>,
	"alan@...ux.intel.com" <alan@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...ux.intel.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"Rafael J. Wysocki" <rjw@...ysocki.net>, Len.Brown@...el.com,
	x86@...nel.org, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86: Bypass legacy PIC and PIT on ACPI hardware reduced
 platform

On 2015/3/5 20:42, Li, Aubrey wrote:
> On 2015/3/5 19:36, Ingo Molnar wrote:
>>
>> * Li, Aubrey <aubrey.li@...ux.intel.com> wrote:
>>
>>> On 2015/3/5 4:11, Ingo Molnar wrote:
>>>>
>>>> * Arjan van de Ven <arjan@...ux.intel.com> wrote:
>>>>
>>>>> On 3/4/2015 1:50 AM, Borislav Petkov wrote:
>>>>>> On Wed, Mar 04, 2015 at 12:43:08AM -0800, Arjan van de Ven wrote:
>>>>>>>>
>>>>>>>> Using 'acpi_gbl_reduced_hardware' flag outside the ACPI code
>>>>>>>> is a mistake.
>>>>>>>
>>>>>>> ideally, the presence of that flag in the firmware table will clear/set more global settings,
>>>>>>> for example, having that flag should cause the 8042 input code to not probe for the 8042.
>>>>>>>
>>>>>>> for interrupts, there really ought to be a "apic first/only" mode, which is then used on
>>>>>>> all modern systems (not just hw reduced).
>>>>>>
>>>>>> Do we need some sort of platform-specific querying interfaces now too,
>>>>>> similar to cpu_has()? I.e., platform_has()...
>>>>>>
>>>>>> 	if (platform_has(X86_PLATFORM_REDUCED_HW))
>>>>>> 		do stuff..
>>>>>
>>>>> more like
>>>>>
>>>>> platform_has(X86_PLATFORM_PIT)
>>>>>
>>>>> etc, one for each legacy io item
>>>>
>>>> Precisely. The main problem is the generic, 'lumps everything 
>>>> together' nature of the acpi_gbl_reduced_hardware flag.
>>>>
>>>> (Like the big kernel lock lumped together all sorts of locking rules 
>>>> and semantics.)
>>>>
>>>> Properly split out, feature-ish or driver-ish interfaces for PIT and 
>>>> other legacy details are the proper approach to 'turn them off'.
>>>>
>>>>  - x86_platform is a function pointer driven, driver-ish interface.
>>>>
>>>>  - platform_has(X86_PLATFORM_IT) is a flag driven, feature-flag-ish
>>>>    interface.
>>>>
>>>> Both are fine - for something as separate as the PIT (or the PIC) 
>>>> it might make more sense to go towards a 'driver' interface 
>>>> though, as modern drivers are (and will be) much different from 
>>>> the legacy PIT.
>>>>
>>>> Whichever method is used, low level platforms can just switch them 
>>>> on/off in their enumeration/detection routines, while the generic 
>>>> code will have them enabled by default.
>>>
>>> Whichever method is used, we will face a problem how to determine 
>>> PIT exists or not.
>>>
>>> When we enabled Bay Trail-T platform at the beginning, we were 
>>> trying to make the code as generic as possible, and it works 
>>> properly up to now. So we don't have a SUBARCH like 
>>> X86_SUBARCH_INTEL_MID to use the platform specific functions. And 
>>> for now I'm not quite sure it's a good idea to create one.
>>>
>>> If we make it as a flag driven, I don't know there is a flag in 
>>> firmware better than ACPI HW reduced flag(Of course it's not good 
>>> enough to cover all the cases). Or if we want to use platform info 
>>> to turn on/off this flag, we'll have to maintain a platform list, 
>>> which may be longer and more complicated than worth doing that.
>>
>> Well, it's not nearly so difficult, because you already have a 
>> platform flag: acpi_gbl_reduced_hardware.
>>
>> What I object against is to infest generic codepaths with unreadable, 
>> unrobust crap like:
>>
>> +       if (acpi_gbl_reduced_hardware) {
>> +               pr_info("Using NULL legacy PIC\n");
>> +               legacy_pic = &null_legacy_pic;
>> +       } else
>> +               legacy_pic->init(0);
>>
>> To solve that, add a small (early) init function (say 
>> 'x86_reduced_hw_init()') that sets up the right driver
>> selections if acpi_gbl_reduced_hardware is set:
>>
>>  - in x86_reduced_hw_init() set 'legacy_pic' to 'null_legacy_pic'
>>
>>  - clean up 'global_clock_event' handling: instead of a global 
>>    variable, move its management into x86_platform_ops::get_clockevent()
>>    and set the method to hpet/pit/abp/etc. specific handlers that
>>    return the right clockevent device.
>>
>>  - in your x86_reduced_hw_init() function add the hpet clockevent
>>    device to x86_platform_ops::get_clockevent, overriding the default
>>    PIT.
>>

how about this one?

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index b9e30da..70955d6 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1541,6 +1541,16 @@ int __init early_acpi_boot_init(void)
 	 */
 	early_acpi_process_madt();

+	/*
+	 * Override x86_init functions and bypass legacy pic
+	 * in hardware-reduced ACPI mode
+	 */
+	if (acpi_gbl_reduced_hardware) {
+		x86_init.timers.timer_init = x86_init_noop;
+		x86_init.irqs.pre_vector_init = x86_init_noop;
+		legacy_pic = &null_legacy_pic;
+	}
+
 	return 0;
 }

> 
>>  - in x86_reduced_hw_init() set pm_power_off.
>>
>>  - set 'reboot_type' and remove the acpi_gbl_reduced_hardware hack
>>    from efi_reboot_required().
>>
> I'll do more investigation above items but I want to leave at least
> these two as the quirk today unless I am convinced I can do that because
> from my understanding, UEFI runtime services should not be supported in
> reduced hw mode.
> 

If the above makes sense, I'll send poweroff and reboot change together
in a seperate patch.

Thanks,
-Aubrey
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ