diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f96afb1230ed5e6deb31c792e3aa70b27bad895e..7d175d3262fe0b78097b526d11660053013af932 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3251,6 +3251,31 @@ bool kvm_arm_supports_user_irq(void) return kvm_check_extension(kvm_state, KVM_CAP_ARM_USER_IRQ); } +void kvm_update_hdbss_cap(bool enable, int hdbss_buffer_size) +{ + KVMState *s = kvm_state; + int size, ret; + + if (s == NULL || !kvm_check_extension(s, KVM_CAP_ARM_HW_DIRTY_STATE_TRACK)) { + return; + } + + size = hdbss_buffer_size; + if (size < 0 || size > MAX_HDBSS_BUFFER_SIZE) { + fprintf(stderr, "Invalid hdbss buffer size: %d\n", size); + return; + } + + ret = kvm_vm_enable_cap(s, KVM_CAP_ARM_HW_DIRTY_STATE_TRACK, 0, + enable ? size : 0); + if (ret) { + fprintf(stderr, "Could not %s KVM_CAP_ARM_HW_DIRTY_STATE_TRACK: %d\n", + enable ? "enable" : "disable", ret); + } + + return; +} + #ifdef KVM_CAP_SET_GUEST_DEBUG struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *cpu, vaddr pc) { diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 1fffdc0ea2dba64d1c2ad4115520b9fcab5d4d7c..e68f3433ad2c816b449eb015be3134f0124d59a5 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -119,6 +119,11 @@ bool kvm_arm_supports_user_irq(void) return false; } +void kvm_update_hdbss_cap(bool enable, int hdbss_buffer_size) +{ + g_assert_not_reached(); +} + bool kvm_dirty_ring_enabled(void) { return false; @@ -128,3 +133,9 @@ uint32_t kvm_dirty_ring_size(void) { return 0; } + +int kvm_load_user_data(hwaddr loader_start, hwaddr image_end, hwaddr initrd_start, hwaddr dtb_end, hwaddr ram_size, + struct kvm_numa_info *numa_info) +{ + return -ENOSYS; +} diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 16cccc881e8e16d28b61f016f73692511c01823d..098257e72f08dff9155d36fe39df1a5786c2fa7c 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -229,6 +229,14 @@ int kvm_has_gsi_routing(void); */ bool kvm_arm_supports_user_irq(void); +/* + * The default HDBSS size. The value ranges [0, 9]. + * Set to 0 to disable the HDBSS feature. + */ +#define DEFAULT_HDBSS_BUFFER_SIZE 0 +#define MAX_HDBSS_BUFFER_SIZE 9 + +void kvm_update_hdbss_cap(bool enable, int hdbss_buffer_size); int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); int kvm_on_sigbus(int code, void *addr); diff --git a/migration/migration.h b/migration/migration.h index 4a95f001574e636ac54d75c9dc96cfb8b4944220..eeddb7c0bde3ec700200820aca6b99bb2544ee9d 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -48,13 +48,6 @@ struct PostcopyBlocktimeContext; */ #define CLEAR_BITMAP_SHIFT_MAX 31 -/* - * The default HDBSS size. The value ranges [0, 9]. - * Set to 0 to disable the HDBSS feature. - */ -#define DEFAULT_HDBSS_BUFFER_SIZE 0 -#define MAX_HDBSS_BUFFER_SIZE 9 - /* This is an abstraction of a "temp huge page" for postcopy's purpose */ typedef struct { /* diff --git a/migration/ram.c b/migration/ram.c index a8308eb005127092b33752ed1ffbfdf5b0915d42..91bec89a6e80d74712594809a1cbe9dada709c89 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2812,33 +2812,6 @@ static void xbzrle_cleanup(void) XBZRLE_cache_unlock(); } -#ifdef TARGET_AARCH64 -static void kvm_update_hdbss_cap(bool enable) -{ - KVMState *s = kvm_state; - int size, ret; - - if (s == NULL || !kvm_check_extension(s, KVM_CAP_ARM_HW_DIRTY_STATE_TRACK)) { - return; - } - - size = migrate_hdbss_buffer_size(); - if (size < 0 || size > MAX_HDBSS_BUFFER_SIZE) { - fprintf(stderr, "Invalid hdbss buffer size: %d\n", size); - return; - } - - ret = kvm_vm_enable_cap(s, KVM_CAP_ARM_HW_DIRTY_STATE_TRACK, 0, - enable ? size : 0); - if (ret) { - fprintf(stderr, "Could not %s KVM_CAP_ARM_HW_DIRTY_STATE_TRACK: %d\n", - enable ? "enable" : "disable", ret); - } - - return; -} -#endif - static void ram_save_cleanup(void *opaque) { RAMState **rsp = opaque; @@ -2856,7 +2829,9 @@ static void ram_save_cleanup(void *opaque) * memory_global_dirty_log_start/stop used in pairs */ #ifdef TARGET_AARCH64 - kvm_update_hdbss_cap(false); + if (kvm_enabled()) { + kvm_update_hdbss_cap(false, 0); + } #endif memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION); } @@ -3262,7 +3237,9 @@ static void ram_init_bitmaps(RAMState *rs) /* We don't use dirty log with background snapshots */ if (!migrate_background_snapshot()) { #ifdef TARGET_AARCH64 - kvm_update_hdbss_cap(true); + if (kvm_enabled()) { + kvm_update_hdbss_cap(true, migrate_hdbss_buffer_size()); + } #endif memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION); migration_bitmap_sync_precopy(rs, false); diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 62fbb713f4f8a3a4c03ec7d5e86c51fa1015caf0..76137289dfaaac275c3e48c75e8b44e57a48cfb5 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -497,6 +497,16 @@ static inline void tmm_add_ram_region(hwaddr base1, hwaddr len1, hwaddr base2, { g_assert_not_reached(); } + +static inline void tmm_set_sec_addr(hwaddr base, int num) +{ + g_assert_not_reached(); +} + +static inline void tmm_set_hpre_addr(hwaddr base, int num) +{ + g_assert_not_reached(); +} #endif /**