qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] target/arm: Needn't validate the target in scratch host
@ 2021-04-07  4:00 Gavin Shan
  2021-04-07  4:01 ` [PATCH 2/2] target/arm: Initlaize PMU feature for scratch vcpu Gavin Shan
  0 siblings, 1 reply; 4+ messages in thread
From: Gavin Shan @ 2021-04-07  4:00 UTC (permalink / raw)
  To: qemu-arm
  Cc: peter.maydell, richard.henderson, qemu-devel, marcin.juszkiewicz,
	shan.gavin, pbonzini

@init->target is always -1 and preferred target is retrieved from
host when @init isn't NULL in kvm_arm_create_scratch_host_vcpu().
So we can have the assumption that preferred target retrived from
host is tried prior to the specified target list.

Signed-off-by: Gavin Shan <gshan@redhat.com>
---
 target/arm/kvm.c   | 15 ++++-----------
 target/arm/kvm64.c | 12 +++++-------
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index d8381ba224..3141d5d313 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -69,6 +69,7 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
                                       int *fdarray,
                                       struct kvm_vcpu_init *init)
 {
+    struct kvm_vcpu_init try;
     int ret = 0, kvmfd = -1, vmfd = -1, cpufd = -1;
 
     kvmfd = qemu_open_old("/dev/kvm", O_RDWR);
@@ -89,15 +90,9 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
         goto finish;
     }
 
-    if (init->target == -1) {
-        struct kvm_vcpu_init preferred;
-
-        ret = ioctl(vmfd, KVM_ARM_PREFERRED_TARGET, &preferred);
-        if (!ret) {
-            init->target = preferred.target;
-        }
-    }
-    if (ret >= 0) {
+    ret = ioctl(vmfd, KVM_ARM_PREFERRED_TARGET, &try);
+    if (!ret) {
+        init->target = try.target;
         ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, init);
         if (ret < 0) {
             goto err;
@@ -108,8 +103,6 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
          * creating one kind of guest CPU which is its preferred
          * CPU type.
          */
-        struct kvm_vcpu_init try;
-
         while (*cpus_to_try != QEMU_KVM_ARM_TARGET_NONE) {
             try.target = *cpus_to_try++;
             memcpy(try.features, init->features, sizeof(init->features));
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index 581335e49d..79800f00a7 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -515,11 +515,9 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
         KVM_ARM_TARGET_CORTEX_A57,
         QEMU_KVM_ARM_TARGET_NONE
     };
-    /*
-     * target = -1 informs kvm_arm_create_scratch_host_vcpu()
-     * to use the preferred target
-     */
-    struct kvm_vcpu_init init = { .target = -1, };
+    struct kvm_vcpu_init init = {
+        .features[0] = 0;
+    };
 
     if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) {
         return false;
@@ -742,8 +740,7 @@ void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map)
      */
     if (!probed) {
         struct kvm_vcpu_init init = {
-            .target = -1,
-            .features[0] = (1 << KVM_ARM_VCPU_SVE),
+            .features[0] = 0,
         };
         struct kvm_one_reg reg = {
             .id = KVM_REG_ARM64_SVE_VLS,
@@ -753,6 +750,7 @@ void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map)
 
         probed = true;
 
+        init.features[0] = (1 << KVM_ARM_VCPU_SVE);
         if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, &init)) {
             error_report("failed to create scratch VCPU with SVE enabled");
             abort();
-- 
2.23.0



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

end of thread, other threads:[~2021-04-12  2:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07  4:00 [PATCH 1/2] target/arm: Needn't validate the target in scratch host Gavin Shan
2021-04-07  4:01 ` [PATCH 2/2] target/arm: Initlaize PMU feature for scratch vcpu Gavin Shan
2021-04-07  7:38   ` Peter Maydell
2021-04-12  4:11     ` Gavin Shan

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).