[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [PATCH 2/2] x86/mtrr: fix build with gcc9
- To: Jan Beulich <JBeulich@xxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Mon, 18 Mar 2019 10:30:02 +0000
- Autocrypt: addr=andrew.cooper3@xxxxxxxxxx; prefer-encrypt=mutual; keydata= mQINBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABtClBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPokCOgQTAQgAJAIbAwULCQgHAwUVCgkI CwUWAgMBAAIeAQIXgAUCWKD95wIZAQAKCRBlw/kGpdefoHbdD/9AIoR3k6fKl+RFiF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xxxxxxxxxxxx>, Wei Liu <wei.liu2@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Delivery-date: Mon, 18 Mar 2019 10:30:21 +0000
- Ironport-data: A9a23:ZAY0tat/h6sl8dWjFJQBFK6JRufnOphVZndcV/efNqXfP3jJ3xfK3H kvQROUoXmQwM+V6GRzblCnoMaGwabH3weRaOapdq5EDlNPp1TMprOnca9L8ATNlkHq+J+DyM 8Qz+d+tCuXfK/K8vH00RrkdcwSuQSiHN83uR5Nv+wVaN9pc8Hr0D13aINz4MwSLQL8NjoXcs 8scLE5xZG9QXx4EswYtdnvHw3vJsDyMQcpXe9sS3t67Kq+c3Ig8z8mOYeDdJqhNEAt/+Svfz Nf1MuohmxqUcUH+uHXC71kIisly9o9ajazC+h8QeHDKGEgPkhLO5+/hsBjrT5TzF5gdCPE+p pepODqY23SzQq5rKctNGBBb/LI58Mutfzz4Evy+JDXa8cNxlFGF31GK7wM3uuM5Xm+3hut9a QeUeml5bn/iCzQNm+AY/2RQzRFqhvUlGHXE+GT71iv4s180nkKBlp5Rko8CsKxKvUDvXLQ+G CFERXJIh+s5bz6L9UbT3AVUxM8B/wMVcHNXRAHjCGxdoU/Y3pwrk8vVjhgWIZrcHT7aRCNJH 9VXn3GWlwTs3yuF6UpOrdIuVW9+8Hi+eET5ABwvzaoGjdKaHVY9FCdRc0vP2O0Ye41BP5xD9 LidIrOW4C93EHzPPw3JlTzhDA8+qRhxWJvjeWqIN3LB+gKFrvV4ufqZcyKR98VDaLBKvixtt XnRi3do/LkyJQmqFOZJcXmgGXK/iyWgYaxigH4OZknCj8QT96zYf1Tw08qM7fdhNBnmscmho YK4v0CeCSSHMvvIRI0Et8IxK+vOCwcQJWnIYhVfr+/crbHo65wsEZZSuSZLlIyO3YEqFjMPa vHrFUhMsJEqWaJATh4t3PZWNXkc1yeNu19n+Kj82NProEduRawjIqiLE5c/hLe/tXWTXYxOe hsW0QKwWQzhY8A/HJ5bY8SR34nd4AEu8wA698sF+rJcr4MKzjaybN+GXc1mng2HRL/u3V8Hk f2lzjCDpbtfMrzaZhKpv31zjM6zTFkTWIhinC0DtbzZh9scBbj9h9SCbNRbkPVF8EUO4hnWc AwI2ze7IpLMXmFduFGg3HhX/jVMaOTOfu9HqTQQNUUDdondzVHXeIc0FgDgc1rizIUOkAewS MOMwBtItxXQnLm5xXwAOfn4jjEGIhrhg+7tJMLlfHyfCfESSXBdjxBKtY3UsLBtmb++1ZlLX Ze3uWepbuaWmGGwif9CovR+UiVc424ZdXe1lzV/IjUaXzuSKTqm2DsjW9/TlewKfUjitjMiF osPvLUXglXx61Ka/GBGjb7WZITUupuEIni+vZ7NgjL5ehEn1EmRipZ2a5Attdq3Vb0teDA77 Uomp725yvmFMjZcUUeHylS+COrJKX32/0OKe9GJrYepswdWcUkDqzAn6qL6KZfa3R0MZLD+3 i52WXJhxmTi8SE/CInOGDIsTOoDEkxv8HkZV/Yf+bZdQ8njSDL37Hhvh0BtU2CosjLCvzByM kcQi75hQ96vdDNypOud180O83kcpaIyDIg9n6m9Wdu8UfTsGnd2eINvPAbLzrsaLf0t8jMV8 W1LS4CfbvWLa6s9QGxjYfTVQuaksSzxe6bLWaRB088LTJMCGA08y9EXYlJW8ZZpXqz5fvk2N y7VgvqbGnJTctW9EXGHPAbnj0ZQzw/ravJx8JU0ZqH901cTEWvKhlhZBZ9iYc4aElYZGv4vH tF1HgUopBfPuKvk3kSv7+CbPJ90ck+b8vEtp+1Nx6LGB4NwSFn/GY4Xn3oUU8QhbIMHKVq3Q 5LsdbgXimyB+9pQKEzjXyFQAYn3LhayZ2d6m432UJBBE5umqr8dGk58fSUEHbcqmpVrpSwJk PC79OsfDJIyban37l81v5/TcnZQKBMlIttxPMOF2OZCxmz71w4FuYO+0xk8emtsJRHp+Ngdq 0GTg==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Openpgp: preference=signencrypt
On 18/03/2019 10:11, Jan Beulich wrote:
>>>> On 15.03.19 at 17:21, <andrew.cooper3@xxxxxxxxxx> wrote:
>> On 07/03/2019 10:32, Jan Beulich wrote:
>>> generic.c: In function ‘print_mtrr_state’:
>>> generic.c:210:11: error: ‘%0*lx’ directive output between 1 and 1073741823
>> bytes may cause result to exceed
>>> ‘INT_MAX’ [-Werror=format-overflow=]
>>> 210 | printk("%s %u base %0*"PRIx64"000 mask %0*"PRIx64"000 %s\n",
>>> | ^~~~~~~~~~~~~~~~~
>>> generic.c:210:44: note: format string is defined here
>>> 210 | printk("%s %u base %0*"PRIx64"000 mask %0*"PRIx64"000 %s\n",
>>> generic.c:210:11: note: directive argument in the range [0,
>> 4503599627370495]
>>> 210 | printk("%s %u base %0*"PRIx64"000 mask %0*"PRIx64"000 %s\n",
>>> | ^~~~~~~~~~~~~~~~~
>>> generic.c:210:11: note: assuming directive output of 1 byte
>>>
>>> Restrict the width of the variable "width" controlling the number of
>>> address digits output.
>>>
>>> Reported-by: Charles Arnold <carnold@xxxxxxxx>
>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> This is because GCC doesn't know the value of paddr_bits, and has
>> concluded that
>>
>> width = (paddr_bits - PAGE_SHIFT + 3) / 4;
>>
>> can result in some insane values, which is true.
>>
>> However, this logic to unnecessarily complicated for something which is
>> only printed in a verbose or error case.
>>
>> I'd prefer this as an alternative:
>>
>> diff --git a/xen/arch/x86/cpu/mtrr/generic.c
>> b/xen/arch/x86/cpu/mtrr/generic.c
>> index 8f9cf1b..566396f 100644
>> --- a/xen/arch/x86/cpu/mtrr/generic.c
>> +++ b/xen/arch/x86/cpu/mtrr/generic.c
>> @@ -182,7 +182,6 @@ static void __init print_fixed(unsigned int base,
>> unsigned int step,
>> static void __init print_mtrr_state(const char *level)
>> {
>> unsigned int i;
>> - int width;
>>
>> printk("%sMTRR default type: %s\n", level,
>> mtrr_attrib_to_str(mtrr_state.def_type));
>> @@ -203,14 +202,13 @@ static void __init print_mtrr_state(const char *level)
>> }
>> printk("%sMTRR variable ranges %sabled:\n", level,
>> mtrr_state.enabled ? "en" : "dis");
>> - width = (paddr_bits - PAGE_SHIFT + 3) / 4;
>>
>> for (i = 0; i < num_var_ranges; ++i) {
>> if (mtrr_state.var_ranges[i].mask & MTRR_PHYSMASK_VALID)
>> - printk("%s %u base %0*"PRIx64"000 mask
>> %0*"PRIx64"000 %s\n",
>> + printk("%s %u base %013"PRIx64"000 mask
>> %013"PRIx64"000 %s\n",
>> level, i,
>> - width, mtrr_state.var_ranges[i].base >> 12,
>> - width, mtrr_state.var_ranges[i].mask >> 12,
>> + mtrr_state.var_ranges[i].base >> 12,
>> + mtrr_state.var_ranges[i].mask >> 12,
> I don't prefer this, and it was done the way it is for a very simple
> reason: By omitting unnecessary leading zeros we convey an
> extra bit of information - this way it is easier to spot if the mask
> values in particular indeed go up all the way to the paddr limit. I
> have at least one system where the BIOS screws up, and there
> end up being leading zeros.
How is that expected to work in the way you describe for the
overwhelming majority of systems with don't have MAXPHYSADDR aligned on
a nibble?
39, 42 and 46 are the widths used in practice by Intel processors, none
of which are divisible by 4.
If you want to print this information out in a useful way, print 1ul <<
paddr_bits so it is obvious in the logs. Your logic of omitting
leading zeros is of no use to the Xen community when you are the only
person who knows what it means.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|