* [PATCH] x86: Use __always_inline to ensure scale_delta linked to vsyscall section.
@ 2009-11-14 4:53 Zhang, Xiantao
2009-11-14 7:10 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Xiantao @ 2009-11-14 4:53 UTC (permalink / raw)
To: Jeremy Fitzhardinge, Xen-devel
[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]
Hi, Jeremy
The attached patch should fix the bug: http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=1529 which blocked us for weeks. Since scale_delta is used in the vsyscall vtime, so it should be inlined and linked to vsycall section, otherwise, dom0 should refuse the call. But due to GCC's optimization, scale_delta is compiled to a global function instead of inline function even if it is declared with inline attribute, so the issue occurs. To ensure this function is inlined to vsyscall section, a stricter attribute __always_inline should be used in its declaration. Thanks!
Xiantao
>From 3290d6e40f6c69ce3edd728f57780f088b7155e3 Mon Sep 17 00:00:00 2001
From: Xiantao Zhang <xiantao.zhang@intel.com>
Date: Fri, 13 Nov 2009 20:33:10 -0500
Subject: [PATCH] x86: Use __always_inline to ensure scale_delta linked to vsyscall section.
scale_delta is called in vsyscall vtime, so it should be linked to vsyscall
section and use fixmap to access it, otherwise unexpected page fault may raise
in vsyscall context, and leads to system dom0 panic.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
arch/x86/kernel/pvclock.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index f47f91e..1b5d3e8 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -28,7 +28,8 @@
* Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
* yielding a 64-bit result.
*/
-static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
+static __always_inline
+u64 scale_delta(u64 delta, u32 mul_frac, int shift)
{
u64 product;
#ifdef __i386__
--
1.6.0.rc1
[-- Attachment #2: 0001-x86-Use-__always_inline-to-ensure-scale_delta-linke.patch --]
[-- Type: application/octet-stream, Size: 1087 bytes --]
From 3290d6e40f6c69ce3edd728f57780f088b7155e3 Mon Sep 17 00:00:00 2001
From: Xiantao Zhang <xiantao.zhang@intel.com>
Date: Fri, 13 Nov 2009 20:33:10 -0500
Subject: [PATCH] x86: Use __always_inline to ensure scale_delta linked to vsyscall section.
scale_delta is called in vsyscall vtime, so it should be linked to vsyscall
section and use fixmap to access it, otherwise unexpected page fault may raise
in vsyscall context, and leads to system dom0 panic.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
arch/x86/kernel/pvclock.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index f47f91e..1b5d3e8 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -28,7 +28,8 @@
* Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
* yielding a 64-bit result.
*/
-static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
+static __always_inline
+u64 scale_delta(u64 delta, u32 mul_frac, int shift)
{
u64 product;
#ifdef __i386__
--
1.6.0.rc1
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] x86: Use __always_inline to ensure scale_delta linked to vsyscall section.
2009-11-14 4:53 [PATCH] x86: Use __always_inline to ensure scale_delta linked to vsyscall section Zhang, Xiantao
@ 2009-11-14 7:10 ` Jeremy Fitzhardinge
0 siblings, 0 replies; 2+ messages in thread
From: Jeremy Fitzhardinge @ 2009-11-14 7:10 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: Xen-devel
On 11/13/09 20:53, Zhang, Xiantao wrote:
> Hi, Jeremy
> The attached patch should fix the bug: http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=1529 which blocked us for weeks. Since scale_delta is used in the vsyscall vtime, so it should be inlined and linked to vsycall section, otherwise, dom0 should refuse the call. But due to GCC's optimization, scale_delta is compiled to a global function instead of inline function even if it is declared with inline attribute, so the issue occurs. To ensure this function is inlined to vsyscall section, a stricter attribute __always_inline should be used in its declaration. Thanks!
>
Thanks for tracking that down.
J
> Xiantao
>
>
> From 3290d6e40f6c69ce3edd728f57780f088b7155e3 Mon Sep 17 00:00:00 2001
> From: Xiantao Zhang <xiantao.zhang@intel.com>
> Date: Fri, 13 Nov 2009 20:33:10 -0500
> Subject: [PATCH] x86: Use __always_inline to ensure scale_delta linked to vsyscall section.
>
> scale_delta is called in vsyscall vtime, so it should be linked to vsyscall
> section and use fixmap to access it, otherwise unexpected page fault may raise
> in vsyscall context, and leads to system dom0 panic.
>
> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
> ---
> arch/x86/kernel/pvclock.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
> index f47f91e..1b5d3e8 100644
> --- a/arch/x86/kernel/pvclock.c
> +++ b/arch/x86/kernel/pvclock.c
> @@ -28,7 +28,8 @@
> * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
> * yielding a 64-bit result.
> */
> -static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
> +static __always_inline
> +u64 scale_delta(u64 delta, u32 mul_frac, int shift)
> {
> u64 product;
> #ifdef __i386__
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-14 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-14 4:53 [PATCH] x86: Use __always_inline to ensure scale_delta linked to vsyscall section Zhang, Xiantao
2009-11-14 7:10 ` Jeremy Fitzhardinge
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.