* [PATCH] kvm-unit-test: x86: Remove duplicate definitions of write_cr4_checking() and put it in library
@ 2019-06-28 21:21 Krish Sadhukhan
2019-07-02 16:11 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Krish Sadhukhan @ 2019-06-28 21:21 UTC (permalink / raw)
To: kvm
..so that it can be re-used.
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com>
---
lib/x86/desc.c | 8 ++++++++
lib/x86/desc.h | 1 +
x86/access.c | 8 --------
x86/pcid.c | 8 --------
x86/vmx_tests.c | 8 --------
x86/xsave.c | 8 --------
6 files changed, 9 insertions(+), 32 deletions(-)
diff --git a/lib/x86/desc.c b/lib/x86/desc.c
index 0108555..5f37cef 100644
--- a/lib/x86/desc.c
+++ b/lib/x86/desc.c
@@ -251,6 +251,14 @@ unsigned exception_vector(void)
return vector;
}
+int write_cr4_checking(unsigned long val)
+{
+ asm volatile(ASM_TRY("1f")
+ "mov %0,%%cr4\n\t"
+ "1:": : "r" (val));
+ return exception_vector();
+}
+
unsigned exception_error_code(void)
{
unsigned short error_code;
diff --git a/lib/x86/desc.h b/lib/x86/desc.h
index 7a7358a..9cf823a 100644
--- a/lib/x86/desc.h
+++ b/lib/x86/desc.h
@@ -207,6 +207,7 @@ extern tss64_t tss;
#endif
unsigned exception_vector(void);
+int write_cr4_checking(unsigned long val);
unsigned exception_error_code(void);
bool exception_rflags_rf(void);
void set_idt_entry(int vec, void *addr, int dpl);
diff --git a/x86/access.c b/x86/access.c
index 9412300..f0d1879 100644
--- a/x86/access.c
+++ b/x86/access.c
@@ -171,14 +171,6 @@ typedef struct {
static void ac_test_show(ac_test_t *at);
-static int write_cr4_checking(unsigned long val)
-{
- asm volatile(ASM_TRY("1f")
- "mov %0,%%cr4\n\t"
- "1:": : "r" (val));
- return exception_vector();
-}
-
static void set_cr0_wp(int wp)
{
unsigned long cr0 = read_cr0();
diff --git a/x86/pcid.c b/x86/pcid.c
index c04fd09..dfabe0e 100644
--- a/x86/pcid.c
+++ b/x86/pcid.c
@@ -21,14 +21,6 @@ static int write_cr0_checking(unsigned long val)
return exception_vector();
}
-static int write_cr4_checking(unsigned long val)
-{
- asm volatile(ASM_TRY("1f")
- "mov %0, %%cr4\n\t"
- "1:": : "r" (val));
- return exception_vector();
-}
-
static int invpcid_checking(unsigned long type, void *desc)
{
asm volatile (ASM_TRY("1f")
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index c48e7fc..7184b06 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -7090,14 +7090,6 @@ static void vmentry_movss_shadow_test(void)
vmcs_write(GUEST_RFLAGS, X86_EFLAGS_FIXED);
}
-static int write_cr4_checking(unsigned long val)
-{
- asm volatile(ASM_TRY("1f")
- "mov %0, %%cr4\n\t"
- "1:": : "r" (val));
- return exception_vector();
-}
-
static void vmx_cr_load_test(void)
{
struct cpuid _cpuid = cpuid(1);
diff --git a/x86/xsave.c b/x86/xsave.c
index 00787bb..ca41bbf 100644
--- a/x86/xsave.c
+++ b/x86/xsave.c
@@ -33,14 +33,6 @@ static int xsetbv_checking(u32 index, u64 value)
return exception_vector();
}
-static int write_cr4_checking(unsigned long val)
-{
- asm volatile(ASM_TRY("1f")
- "mov %0,%%cr4\n\t"
- "1:": : "r" (val));
- return exception_vector();
-}
-
#define CPUID_1_ECX_XSAVE (1 << 26)
#define CPUID_1_ECX_OSXSAVE (1 << 27)
static int check_cpuid_1_ecx(unsigned int bit)
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kvm-unit-test: x86: Remove duplicate definitions of write_cr4_checking() and put it in library
2019-06-28 21:21 [PATCH] kvm-unit-test: x86: Remove duplicate definitions of write_cr4_checking() and put it in library Krish Sadhukhan
@ 2019-07-02 16:11 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2019-07-02 16:11 UTC (permalink / raw)
To: Krish Sadhukhan, kvm
On 28/06/19 23:21, Krish Sadhukhan wrote:
> ..so that it can be re-used.
>
> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com>
>
> ---
> lib/x86/desc.c | 8 ++++++++
> lib/x86/desc.h | 1 +
> x86/access.c | 8 --------
> x86/pcid.c | 8 --------
> x86/vmx_tests.c | 8 --------
> x86/xsave.c | 8 --------
> 6 files changed, 9 insertions(+), 32 deletions(-)
>
> diff --git a/lib/x86/desc.c b/lib/x86/desc.c
> index 0108555..5f37cef 100644
> --- a/lib/x86/desc.c
> +++ b/lib/x86/desc.c
> @@ -251,6 +251,14 @@ unsigned exception_vector(void)
> return vector;
> }
>
> +int write_cr4_checking(unsigned long val)
> +{
> + asm volatile(ASM_TRY("1f")
> + "mov %0,%%cr4\n\t"
> + "1:": : "r" (val));
> + return exception_vector();
> +}
> +
> unsigned exception_error_code(void)
> {
> unsigned short error_code;
> diff --git a/lib/x86/desc.h b/lib/x86/desc.h
> index 7a7358a..9cf823a 100644
> --- a/lib/x86/desc.h
> +++ b/lib/x86/desc.h
> @@ -207,6 +207,7 @@ extern tss64_t tss;
> #endif
>
> unsigned exception_vector(void);
> +int write_cr4_checking(unsigned long val);
> unsigned exception_error_code(void);
> bool exception_rflags_rf(void);
> void set_idt_entry(int vec, void *addr, int dpl);
> diff --git a/x86/access.c b/x86/access.c
> index 9412300..f0d1879 100644
> --- a/x86/access.c
> +++ b/x86/access.c
> @@ -171,14 +171,6 @@ typedef struct {
>
> static void ac_test_show(ac_test_t *at);
>
> -static int write_cr4_checking(unsigned long val)
> -{
> - asm volatile(ASM_TRY("1f")
> - "mov %0,%%cr4\n\t"
> - "1:": : "r" (val));
> - return exception_vector();
> -}
> -
> static void set_cr0_wp(int wp)
> {
> unsigned long cr0 = read_cr0();
> diff --git a/x86/pcid.c b/x86/pcid.c
> index c04fd09..dfabe0e 100644
> --- a/x86/pcid.c
> +++ b/x86/pcid.c
> @@ -21,14 +21,6 @@ static int write_cr0_checking(unsigned long val)
> return exception_vector();
> }
>
> -static int write_cr4_checking(unsigned long val)
> -{
> - asm volatile(ASM_TRY("1f")
> - "mov %0, %%cr4\n\t"
> - "1:": : "r" (val));
> - return exception_vector();
> -}
> -
> static int invpcid_checking(unsigned long type, void *desc)
> {
> asm volatile (ASM_TRY("1f")
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index c48e7fc..7184b06 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -7090,14 +7090,6 @@ static void vmentry_movss_shadow_test(void)
> vmcs_write(GUEST_RFLAGS, X86_EFLAGS_FIXED);
> }
>
> -static int write_cr4_checking(unsigned long val)
> -{
> - asm volatile(ASM_TRY("1f")
> - "mov %0, %%cr4\n\t"
> - "1:": : "r" (val));
> - return exception_vector();
> -}
> -
> static void vmx_cr_load_test(void)
> {
> struct cpuid _cpuid = cpuid(1);
> diff --git a/x86/xsave.c b/x86/xsave.c
> index 00787bb..ca41bbf 100644
> --- a/x86/xsave.c
> +++ b/x86/xsave.c
> @@ -33,14 +33,6 @@ static int xsetbv_checking(u32 index, u64 value)
> return exception_vector();
> }
>
> -static int write_cr4_checking(unsigned long val)
> -{
> - asm volatile(ASM_TRY("1f")
> - "mov %0,%%cr4\n\t"
> - "1:": : "r" (val));
> - return exception_vector();
> -}
> -
> #define CPUID_1_ECX_XSAVE (1 << 26)
> #define CPUID_1_ECX_OSXSAVE (1 << 27)
> static int check_cpuid_1_ecx(unsigned int bit)
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-02 16:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28 21:21 [PATCH] kvm-unit-test: x86: Remove duplicate definitions of write_cr4_checking() and put it in library Krish Sadhukhan
2019-07-02 16:11 ` Paolo Bonzini
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).