diff mbox

[kvm-unit-tests,v2,3/5] powerpc: check 64bit mode

Message ID 1458560014-28862-4-git-send-email-lvivier@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Vivier March 21, 2016, 11:33 a.m. UTC
Check in MSR if the SF bit is set (64bit mode is enabled)

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 powerpc/emulator.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

David Gibson March 21, 2016, 11:49 p.m. UTC | #1
On Mon, 21 Mar 2016 12:33:32 +0100
Laurent Vivier <lvivier@redhat.com> wrote:

> Check in MSR if the SF bit is set (64bit mode is enabled)
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  powerpc/emulator.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/powerpc/emulator.c b/powerpc/emulator.c
> index 1d4f164..d97090c 100644
> --- a/powerpc/emulator.c
> +++ b/powerpc/emulator.c
> @@ -43,6 +43,19 @@ static void test_illegal(void)
>  	report_prefix_pop();
>  }
>  
> +static void test_64bit(void)
> +{
> +	uint64_t msr;
> +
> +	report_prefix_push("64bit");
> +
> +	asm("mfmsr %[msr]": [msr] "=r" (msr));
> +
> +	report("detected", msr & 0x8000000000000000UL);
> +
> +	report_prefix_pop();
> +}
> +
>  int main(int argc, char **argv)
>  {
>  	int i;
> @@ -57,6 +70,7 @@ int main(int argc, char **argv)
>  
>  	report_prefix_push("emulator");
>  
> +	test_64bit();
>  	test_illegal();
>  
>  	report_prefix_pop();
> -- 
> 2.5.0
>
diff mbox

Patch

diff --git a/powerpc/emulator.c b/powerpc/emulator.c
index 1d4f164..d97090c 100644
--- a/powerpc/emulator.c
+++ b/powerpc/emulator.c
@@ -43,6 +43,19 @@  static void test_illegal(void)
 	report_prefix_pop();
 }
 
+static void test_64bit(void)
+{
+	uint64_t msr;
+
+	report_prefix_push("64bit");
+
+	asm("mfmsr %[msr]": [msr] "=r" (msr));
+
+	report("detected", msr & 0x8000000000000000UL);
+
+	report_prefix_pop();
+}
+
 int main(int argc, char **argv)
 {
 	int i;
@@ -57,6 +70,7 @@  int main(int argc, char **argv)
 
 	report_prefix_push("emulator");
 
+	test_64bit();
 	test_illegal();
 
 	report_prefix_pop();