From: Xiang Zheng <zhengxiang9@huawei.com> To: <pbonzini@redhat.com>, <mst@redhat.com>, <imammedo@redhat.com>, <shannon.zhaosl@gmail.com>, <peter.maydell@linaro.org>, <lersek@redhat.com>, <james.morse@arm.com>, <gengdongjiu@huawei.com>, <mtosatti@redhat.com>, <rth@twiddle.net>, <ehabkost@redhat.com>, <jonathan.cameron@huawei.com>, <xuwei5@huawei.com>, <kvm@vger.kernel.org>, <qemu-devel@nongnu.org>, <qemu-arm@nongnu.org>, <linuxarm@huawei.com> Cc: <zhengxiang9@huawei.com>, <wanghaibin.wang@huawei.com> Subject: [PATCH v18 4/6] KVM: Move hwpoison page related functions into include/sysemu/kvm_int.h Date: Fri, 6 Sep 2019 16:31:50 +0800 [thread overview] Message-ID: <20190906083152.25716-5-zhengxiang9@huawei.com> (raw) In-Reply-To: <20190906083152.25716-1-zhengxiang9@huawei.com> From: Dongjiu Geng <gengdongjiu@huawei.com> kvm_hwpoison_page_add() and kvm_unpoison_all() will both be used by X86 and ARM platforms, so moving them into "include/sysemu/kvm_int.h" to avoid duplicate code. Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com> Signed-off-by: Xiang Zheng <zhengxiang9@huawei.com> --- accel/kvm/kvm-all.c | 33 +++++++++++++++++++++++++++++++++ include/sysemu/kvm_int.h | 23 +++++++++++++++++++++++ target/arm/kvm.c | 3 +++ target/i386/kvm.c | 34 ---------------------------------- 4 files changed, 59 insertions(+), 34 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b09bad0804..c6c052ba57 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -821,6 +821,39 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension) return ret; } +typedef struct HWPoisonPage { + ram_addr_t ram_addr; + QLIST_ENTRY(HWPoisonPage) list; +} HWPoisonPage; + +static QLIST_HEAD(, HWPoisonPage) hwpoison_page_list = + QLIST_HEAD_INITIALIZER(hwpoison_page_list); + +void kvm_unpoison_all(void *param) +{ + HWPoisonPage *page, *next_page; + + QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) { + QLIST_REMOVE(page, list); + qemu_ram_remap(page->ram_addr, TARGET_PAGE_SIZE); + g_free(page); + } +} + +void kvm_hwpoison_page_add(ram_addr_t ram_addr) +{ + HWPoisonPage *page; + + QLIST_FOREACH(page, &hwpoison_page_list, list) { + if (page->ram_addr == ram_addr) { + return; + } + } + page = g_new(HWPoisonPage, 1); + page->ram_addr = ram_addr; + QLIST_INSERT_HEAD(&hwpoison_page_list, page, list); +} + static uint32_t adjust_ioeventfd_endianness(uint32_t val, uint32_t size) { #if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 72b2d1b3ae..3ad49f9a28 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -41,4 +41,27 @@ typedef struct KVMMemoryListener { void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, AddressSpace *as, int as_id); +/** + * kvm_hwpoison_page_add: + * + * Parameters: + * @ram_addr: the address in the RAM for the poisoned page + * + * Add a poisoned page to the list + * + * Return: None. + */ +void kvm_hwpoison_page_add(ram_addr_t ram_addr); + +/** + * kvm_unpoison_all: + * + * Parameters: + * @param: some data may be passed to this function + * + * Free and remove all the poisoned pages in the list + * + * Return: None. + */ +void kvm_unpoison_all(void *param); #endif diff --git a/target/arm/kvm.c b/target/arm/kvm.c index b2eaa50b8d..3a110be7b8 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -20,6 +20,7 @@ #include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "sysemu/kvm_int.h" +#include "sysemu/reset.h" #include "kvm_arm.h" #include "cpu.h" #include "trace.h" @@ -195,6 +196,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_has_mp_state = kvm_check_extension(s, KVM_CAP_MP_STATE); + qemu_register_reset(kvm_unpoison_all, NULL); + return 0; } diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 8023c679ea..4f9f3682ee 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -476,40 +476,6 @@ uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index) return msr_data.entries[0].data; } - -typedef struct HWPoisonPage { - ram_addr_t ram_addr; - QLIST_ENTRY(HWPoisonPage) list; -} HWPoisonPage; - -static QLIST_HEAD(, HWPoisonPage) hwpoison_page_list = - QLIST_HEAD_INITIALIZER(hwpoison_page_list); - -static void kvm_unpoison_all(void *param) -{ - HWPoisonPage *page, *next_page; - - QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) { - QLIST_REMOVE(page, list); - qemu_ram_remap(page->ram_addr, TARGET_PAGE_SIZE); - g_free(page); - } -} - -static void kvm_hwpoison_page_add(ram_addr_t ram_addr) -{ - HWPoisonPage *page; - - QLIST_FOREACH(page, &hwpoison_page_list, list) { - if (page->ram_addr == ram_addr) { - return; - } - } - page = g_new(HWPoisonPage, 1); - page->ram_addr = ram_addr; - QLIST_INSERT_HEAD(&hwpoison_page_list, page, list); -} - static int kvm_get_mce_cap_supported(KVMState *s, uint64_t *mce_cap, int *max_banks) { -- 2.19.1
WARNING: multiple messages have this Message-ID (diff)
From: Xiang Zheng <zhengxiang9@huawei.com> To: <pbonzini@redhat.com>, <mst@redhat.com>, <imammedo@redhat.com>, <shannon.zhaosl@gmail.com>, <peter.maydell@linaro.org>, <lersek@redhat.com>, <james.morse@arm.com>, <gengdongjiu@huawei.com>, <mtosatti@redhat.com>, <rth@twiddle.net>, <ehabkost@redhat.com>, <jonathan.cameron@huawei.com>, <xuwei5@huawei.com>, <kvm@vger.kernel.org>, <qemu-devel@nongnu.org>, <qemu-arm@nongnu.org>, <linuxarm@huawei.com> Cc: wanghaibin.wang@huawei.com, zhengxiang9@huawei.com Subject: [Qemu-devel] [PATCH v18 4/6] KVM: Move hwpoison page related functions into include/sysemu/kvm_int.h Date: Fri, 6 Sep 2019 16:31:50 +0800 [thread overview] Message-ID: <20190906083152.25716-5-zhengxiang9@huawei.com> (raw) In-Reply-To: <20190906083152.25716-1-zhengxiang9@huawei.com> From: Dongjiu Geng <gengdongjiu@huawei.com> kvm_hwpoison_page_add() and kvm_unpoison_all() will both be used by X86 and ARM platforms, so moving them into "include/sysemu/kvm_int.h" to avoid duplicate code. Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com> Signed-off-by: Xiang Zheng <zhengxiang9@huawei.com> --- accel/kvm/kvm-all.c | 33 +++++++++++++++++++++++++++++++++ include/sysemu/kvm_int.h | 23 +++++++++++++++++++++++ target/arm/kvm.c | 3 +++ target/i386/kvm.c | 34 ---------------------------------- 4 files changed, 59 insertions(+), 34 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b09bad0804..c6c052ba57 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -821,6 +821,39 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension) return ret; } +typedef struct HWPoisonPage { + ram_addr_t ram_addr; + QLIST_ENTRY(HWPoisonPage) list; +} HWPoisonPage; + +static QLIST_HEAD(, HWPoisonPage) hwpoison_page_list = + QLIST_HEAD_INITIALIZER(hwpoison_page_list); + +void kvm_unpoison_all(void *param) +{ + HWPoisonPage *page, *next_page; + + QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) { + QLIST_REMOVE(page, list); + qemu_ram_remap(page->ram_addr, TARGET_PAGE_SIZE); + g_free(page); + } +} + +void kvm_hwpoison_page_add(ram_addr_t ram_addr) +{ + HWPoisonPage *page; + + QLIST_FOREACH(page, &hwpoison_page_list, list) { + if (page->ram_addr == ram_addr) { + return; + } + } + page = g_new(HWPoisonPage, 1); + page->ram_addr = ram_addr; + QLIST_INSERT_HEAD(&hwpoison_page_list, page, list); +} + static uint32_t adjust_ioeventfd_endianness(uint32_t val, uint32_t size) { #if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 72b2d1b3ae..3ad49f9a28 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -41,4 +41,27 @@ typedef struct KVMMemoryListener { void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, AddressSpace *as, int as_id); +/** + * kvm_hwpoison_page_add: + * + * Parameters: + * @ram_addr: the address in the RAM for the poisoned page + * + * Add a poisoned page to the list + * + * Return: None. + */ +void kvm_hwpoison_page_add(ram_addr_t ram_addr); + +/** + * kvm_unpoison_all: + * + * Parameters: + * @param: some data may be passed to this function + * + * Free and remove all the poisoned pages in the list + * + * Return: None. + */ +void kvm_unpoison_all(void *param); #endif diff --git a/target/arm/kvm.c b/target/arm/kvm.c index b2eaa50b8d..3a110be7b8 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -20,6 +20,7 @@ #include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "sysemu/kvm_int.h" +#include "sysemu/reset.h" #include "kvm_arm.h" #include "cpu.h" #include "trace.h" @@ -195,6 +196,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_has_mp_state = kvm_check_extension(s, KVM_CAP_MP_STATE); + qemu_register_reset(kvm_unpoison_all, NULL); + return 0; } diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 8023c679ea..4f9f3682ee 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -476,40 +476,6 @@ uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index) return msr_data.entries[0].data; } - -typedef struct HWPoisonPage { - ram_addr_t ram_addr; - QLIST_ENTRY(HWPoisonPage) list; -} HWPoisonPage; - -static QLIST_HEAD(, HWPoisonPage) hwpoison_page_list = - QLIST_HEAD_INITIALIZER(hwpoison_page_list); - -static void kvm_unpoison_all(void *param) -{ - HWPoisonPage *page, *next_page; - - QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) { - QLIST_REMOVE(page, list); - qemu_ram_remap(page->ram_addr, TARGET_PAGE_SIZE); - g_free(page); - } -} - -static void kvm_hwpoison_page_add(ram_addr_t ram_addr) -{ - HWPoisonPage *page; - - QLIST_FOREACH(page, &hwpoison_page_list, list) { - if (page->ram_addr == ram_addr) { - return; - } - } - page = g_new(HWPoisonPage, 1); - page->ram_addr = ram_addr; - QLIST_INSERT_HEAD(&hwpoison_page_list, page, list); -} - static int kvm_get_mce_cap_supported(KVMState *s, uint64_t *mce_cap, int *max_banks) { -- 2.19.1
next prev parent reply other threads:[~2019-09-06 8:33 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-06 8:31 [PATCH v18 0/6] Add ARMv8 RAS virtualization support in QEMU Xiang Zheng 2019-09-06 8:31 ` [Qemu-devel] " Xiang Zheng 2019-09-06 8:31 ` [PATCH v18 1/6] hw/arm/virt: Introduce RAS platform version and RAS machine option Xiang Zheng 2019-09-06 8:31 ` [Qemu-devel] " Xiang Zheng 2019-09-27 14:02 ` Peter Maydell 2019-09-27 14:02 ` Peter Maydell 2019-09-29 2:04 ` Xiang Zheng 2019-09-29 2:04 ` Xiang Zheng 2019-09-06 8:31 ` [PATCH v18 2/6] docs: APEI GHES generation and CPER record description Xiang Zheng 2019-09-06 8:31 ` [Qemu-devel] " Xiang Zheng 2019-09-19 13:25 ` Peter Maydell 2019-09-19 13:25 ` [Qemu-devel] " Peter Maydell 2019-09-20 1:45 ` Xiang Zheng 2019-09-20 1:45 ` Xiang Zheng 2019-10-04 8:20 ` [Qemu-devel] " Igor Mammedov 2019-10-04 8:20 ` Igor Mammedov 2019-10-08 13:25 ` Xiang Zheng 2019-10-08 13:25 ` Xiang Zheng 2019-09-06 8:31 ` [PATCH v18 3/6] ACPI: Add APEI GHES table generation support Xiang Zheng 2019-09-06 8:31 ` [Qemu-devel] " Xiang Zheng 2019-09-27 15:43 ` Michael S. Tsirkin 2019-09-27 15:43 ` Michael S. Tsirkin 2019-10-08 6:00 ` Xiang Zheng 2019-10-08 6:00 ` Xiang Zheng 2019-10-08 7:45 ` Michael S. Tsirkin 2019-10-08 7:45 ` Michael S. Tsirkin 2019-10-08 12:48 ` Xiang Zheng 2019-10-08 12:48 ` Xiang Zheng 2019-09-06 8:31 ` Xiang Zheng [this message] 2019-09-06 8:31 ` [Qemu-devel] [PATCH v18 4/6] KVM: Move hwpoison page related functions into include/sysemu/kvm_int.h Xiang Zheng 2019-09-27 13:19 ` [Qemu-arm] " Peter Maydell 2019-09-27 13:19 ` Peter Maydell 2019-10-08 7:01 ` Xiang Zheng 2019-10-08 7:01 ` Xiang Zheng 2019-09-06 8:31 ` [PATCH v18 5/6] target-arm: kvm64: inject synchronous External Abort Xiang Zheng 2019-09-06 8:31 ` [Qemu-devel] " Xiang Zheng 2019-09-27 13:33 ` Peter Maydell 2019-09-27 13:33 ` Peter Maydell 2019-10-08 8:05 ` Xiang Zheng 2019-10-08 8:05 ` Xiang Zheng 2019-09-06 8:31 ` [PATCH v18 6/6] target-arm: kvm64: handle SIGBUS signal from kernel or KVM Xiang Zheng 2019-09-06 8:31 ` [Qemu-devel] " Xiang Zheng 2019-09-27 13:57 ` Peter Maydell 2019-09-27 13:57 ` Peter Maydell 2019-10-08 12:42 ` Xiang Zheng 2019-10-08 12:42 ` Xiang Zheng 2019-09-17 12:39 ` [PATCH v18 0/6] Add ARMv8 RAS virtualization support in QEMU Xiang Zheng 2019-09-17 12:39 ` [Qemu-devel] " Xiang Zheng 2019-09-20 2:07 ` gengdongjiu 2019-09-20 2:07 ` gengdongjiu 2019-09-27 14:03 ` [Qemu-arm] " Peter Maydell 2019-09-27 14:03 ` Peter Maydell
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190906083152.25716-5-zhengxiang9@huawei.com \ --to=zhengxiang9@huawei.com \ --cc=ehabkost@redhat.com \ --cc=gengdongjiu@huawei.com \ --cc=imammedo@redhat.com \ --cc=james.morse@arm.com \ --cc=jonathan.cameron@huawei.com \ --cc=kvm@vger.kernel.org \ --cc=lersek@redhat.com \ --cc=linuxarm@huawei.com \ --cc=mst@redhat.com \ --cc=mtosatti@redhat.com \ --cc=pbonzini@redhat.com \ --cc=peter.maydell@linaro.org \ --cc=qemu-arm@nongnu.org \ --cc=qemu-devel@nongnu.org \ --cc=rth@twiddle.net \ --cc=shannon.zhaosl@gmail.com \ --cc=wanghaibin.wang@huawei.com \ --cc=xuwei5@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.