All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.3 v2] cpus: Don't kick un-realized cpus.
@ 2015-03-23 10:47 Peter Crosthwaite
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Crosthwaite @ 2015-03-23 10:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonizni

following a464982499b2f637f6699e3d03e0a9d2e0b5288b, it's now possible for
there to be attempts to take the BQL before CPUs have been realized in
cases where a machine model inits peripherals before the first CPU.

BQL lock aquisition kicks the first_cpu, leading to a segfault if this
happens pre-realize. Guard the CPU kick routine to perform no action for
a CPU that doesn't exist or doesn't have a thread yet.

There was a fix to this with commit
6b49809c597331803ea941eadda813e5bb4e8fe2, but the check there misses
the case where the CPU has been inited and not realized. Strengthen the
check to make sure that the first_cpu has a thread (i.e. it is
realized) before allowing the kick.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
Fixed since V1:
Change implementation to match 6b49809c597331803ea941eadda813e5bb4e8fe2
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 314df16..e6dcae3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1119,7 +1119,7 @@ bool qemu_in_vcpu_thread(void)
 void qemu_mutex_lock_iothread(void)
 {
     atomic_inc(&iothread_requesting_mutex);
-    if (!tcg_enabled() || !first_cpu) {
+    if (!tcg_enabled() || !first_cpu || !first_cpu->thread) {
         qemu_mutex_lock(&qemu_global_mutex);
         atomic_dec(&iothread_requesting_mutex);
     } else {
-- 
2.3.1.2.g90df61e.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.3 v2] cpus: Don't kick un-realized cpus.
  2015-03-23 10:48 Peter Crosthwaite
@ 2015-03-23 12:07 ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2015-03-23 12:07 UTC (permalink / raw)
  To: Peter Crosthwaite, qemu-devel



On 23/03/2015 11:48, Peter Crosthwaite wrote:
> following a464982499b2f637f6699e3d03e0a9d2e0b5288b, it's now possible for
> there to be attempts to take the BQL before CPUs have been realized in
> cases where a machine model inits peripherals before the first CPU.
> 
> BQL lock aquisition kicks the first_cpu, leading to a segfault if this
> happens pre-realize. Guard the CPU kick routine to perform no action for
> a CPU that doesn't exist or doesn't have a thread yet.
> 
> There was a fix to this with commit
> 6b49809c597331803ea941eadda813e5bb4e8fe2, but the check there misses
> the case where the CPU has been inited and not realized. Strengthen the
> check to make sure that the first_cpu has a thread (i.e. it is
> realized) before allowing the kick.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> Fixed since V1:
> Change implementation to match 6b49809c597331803ea941eadda813e5bb4e8fe2
> ---
>  cpus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 314df16..e6dcae3 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1119,7 +1119,7 @@ bool qemu_in_vcpu_thread(void)
>  void qemu_mutex_lock_iothread(void)
>  {
>      atomic_inc(&iothread_requesting_mutex);
> -    if (!tcg_enabled() || !first_cpu) {
> +    if (!tcg_enabled() || !first_cpu || !first_cpu->thread) {
>          qemu_mutex_lock(&qemu_global_mutex);
>          atomic_dec(&iothread_requesting_mutex);
>      } else {
> 

Thanks, applied.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH for-2.3 v2] cpus: Don't kick un-realized cpus.
@ 2015-03-23 10:48 Peter Crosthwaite
  2015-03-23 12:07 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Crosthwaite @ 2015-03-23 10:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini

following a464982499b2f637f6699e3d03e0a9d2e0b5288b, it's now possible for
there to be attempts to take the BQL before CPUs have been realized in
cases where a machine model inits peripherals before the first CPU.

BQL lock aquisition kicks the first_cpu, leading to a segfault if this
happens pre-realize. Guard the CPU kick routine to perform no action for
a CPU that doesn't exist or doesn't have a thread yet.

There was a fix to this with commit
6b49809c597331803ea941eadda813e5bb4e8fe2, but the check there misses
the case where the CPU has been inited and not realized. Strengthen the
check to make sure that the first_cpu has a thread (i.e. it is
realized) before allowing the kick.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
Fixed since V1:
Change implementation to match 6b49809c597331803ea941eadda813e5bb4e8fe2
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 314df16..e6dcae3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1119,7 +1119,7 @@ bool qemu_in_vcpu_thread(void)
 void qemu_mutex_lock_iothread(void)
 {
     atomic_inc(&iothread_requesting_mutex);
-    if (!tcg_enabled() || !first_cpu) {
+    if (!tcg_enabled() || !first_cpu || !first_cpu->thread) {
         qemu_mutex_lock(&qemu_global_mutex);
         atomic_dec(&iothread_requesting_mutex);
     } else {
-- 
2.3.1.2.g90df61e.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH for-2.3 v2] cpus: Don't kick un-realized cpus.
@ 2015-03-23 10:41 Peter Crosthwaite
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Crosthwaite @ 2015-03-23 10:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonizni

following a464982499b2f637f6699e3d03e0a9d2e0b5288b, it's now possible for
there to be attempts to take the BQL before CPUs have been realized in
cases where a machine model inits peripherals before the first CPU.

BQL lock aquisition kicks the first_cpu, leading to a segfault if this
happens pre-realize. Guard the CPU kick routine to perform no action for
a CPU that doesn't exist or doesn't have a thread yet.

There was a fix to this with commit
6b49809c597331803ea941eadda813e5bb4e8fe2, but the check there misses
the case where the CPU has been inited and not realized. Strengthen the
check to make sure that the first_cpu has a thread (i.e. it is
realized) before allowing the kick.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
Fixed since V1:
Change implementation to match 6b49809c597331803ea941eadda813e5bb4e8fe2
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 314df16..e6dcae3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1119,7 +1119,7 @@ bool qemu_in_vcpu_thread(void)
 void qemu_mutex_lock_iothread(void)
 {
     atomic_inc(&iothread_requesting_mutex);
-    if (!tcg_enabled() || !first_cpu) {
+    if (!tcg_enabled() || !first_cpu || !first_cpu->thread) {
         qemu_mutex_lock(&qemu_global_mutex);
         atomic_dec(&iothread_requesting_mutex);
     } else {
-- 
2.3.1.2.g90df61e.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-23 12:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 10:47 [Qemu-devel] [PATCH for-2.3 v2] cpus: Don't kick un-realized cpus Peter Crosthwaite
  -- strict thread matches above, loose matches on Subject: below --
2015-03-23 10:48 Peter Crosthwaite
2015-03-23 12:07 ` Paolo Bonzini
2015-03-23 10:41 Peter Crosthwaite

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.