* [PATCH] kvm/i386: fix a check that ensures we are running on host intel CPU
@ 2024-09-03 7:19 Ani Sinha
2024-09-03 7:43 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Ani Sinha @ 2024-09-03 7:19 UTC (permalink / raw)
To: Paolo Bonzini, Marcelo Tosatti; +Cc: Ani Sinha, kvm, qemu-devel
is_host_cpu_intel() returns TRUE if the host cpu in Intel based. RAPL needs
Intel host cpus. If the host CPU is not Intel baseed, we should report error.
Fix the check accordingly.
Signed-off-by: Ani Sinha <anisinha@redhat.com>
---
target/i386/kvm/kvm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 11c7619bfd..503e8d956e 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2898,7 +2898,7 @@ static int kvm_msr_energy_thread_init(KVMState *s, MachineState *ms)
* 1. Host cpu must be Intel cpu
* 2. RAPL must be enabled on the Host
*/
- if (is_host_cpu_intel()) {
+ if (!is_host_cpu_intel()) {
error_report("The RAPL feature can only be enabled on hosts\
with Intel CPU models");
ret = 1;
--
2.42.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] kvm/i386: fix a check that ensures we are running on host intel CPU
2024-09-03 7:19 [PATCH] kvm/i386: fix a check that ensures we are running on host intel CPU Ani Sinha
@ 2024-09-03 7:43 ` Paolo Bonzini
2024-09-03 8:00 ` Ani Sinha
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2024-09-03 7:43 UTC (permalink / raw)
To: Ani Sinha, Marcelo Tosatti; +Cc: kvm, qemu-devel
On 9/3/24 09:19, Ani Sinha wrote:
> is_host_cpu_intel() returns TRUE if the host cpu in Intel based. RAPL needs
> Intel host cpus. If the host CPU is not Intel baseed, we should report error.
> Fix the check accordingly.
>
> Signed-off-by: Ani Sinha <anisinha@redhat.com>
It's the function that is returning the incorrect value too; so your
patch is breaking the feature: this line in is_host_cpu_intel()
return strcmp(vendor, CPUID_VENDOR_INTEL);
needs to be changed to use g_str_equal.
Paolo
> ---
> target/i386/kvm/kvm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index 11c7619bfd..503e8d956e 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -2898,7 +2898,7 @@ static int kvm_msr_energy_thread_init(KVMState *s, MachineState *ms)
> * 1. Host cpu must be Intel cpu
> * 2. RAPL must be enabled on the Host
> */
> - if (is_host_cpu_intel()) {
> + if (!is_host_cpu_intel()) {
> error_report("The RAPL feature can only be enabled on hosts\
> with Intel CPU models");
> ret = 1;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] kvm/i386: fix a check that ensures we are running on host intel CPU
2024-09-03 7:43 ` Paolo Bonzini
@ 2024-09-03 8:00 ` Ani Sinha
0 siblings, 0 replies; 3+ messages in thread
From: Ani Sinha @ 2024-09-03 8:00 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Marcelo Tosatti, kvm, qemu-devel
> On 3 Sep 2024, at 1:13 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 9/3/24 09:19, Ani Sinha wrote:
>> is_host_cpu_intel() returns TRUE if the host cpu in Intel based. RAPL needs
>> Intel host cpus. If the host CPU is not Intel baseed, we should report error.
>> Fix the check accordingly.
>> Signed-off-by: Ani Sinha <anisinha@redhat.com>
>
> It's the function that is returning the incorrect value too; so your patch is breaking the feature: this line in is_host_cpu_intel()
>
> return strcmp(vendor, CPUID_VENDOR_INTEL);
>
> needs to be changed to use g_str_equal.
Ah that is why it got unnoticed as programatically it was not broken. I will send a v2.
>
> Paolo
>
>> ---
>> target/i386/kvm/kvm.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
>> index 11c7619bfd..503e8d956e 100644
>> --- a/target/i386/kvm/kvm.c
>> +++ b/target/i386/kvm/kvm.c
>> @@ -2898,7 +2898,7 @@ static int kvm_msr_energy_thread_init(KVMState *s, MachineState *ms)
>> * 1. Host cpu must be Intel cpu
>> * 2. RAPL must be enabled on the Host
>> */
>> - if (is_host_cpu_intel()) {
>> + if (!is_host_cpu_intel()) {
>> error_report("The RAPL feature can only be enabled on hosts\
>> with Intel CPU models");
>> ret = 1;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-03 8:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 7:19 [PATCH] kvm/i386: fix a check that ensures we are running on host intel CPU Ani Sinha
2024-09-03 7:43 ` Paolo Bonzini
2024-09-03 8:00 ` Ani Sinha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox