From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932686AbdC2Nyt (ORCPT ); Wed, 29 Mar 2017 09:54:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40854 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932219AbdC2Nys (ORCPT ); Wed, 29 Mar 2017 09:54:48 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B66EB80084 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B66EB80084 Date: Wed, 29 Mar 2017 16:54:41 +0300 From: "Michael S. Tsirkin" To: Laszlo Ersek Cc: Achin Gupta , gengdongjiu , ard.biesheuvel@linaro.org, edk2-devel@ml01.01.org, qemu-devel@nongnu.org, zhaoshenglong@huawei.com, James Morse , Christoffer Dall , xiexiuqi@huawei.com, Marc Zyngier , catalin.marinas@arm.com, will.deacon@arm.com, christoffer.dall@linaro.org, rkrcmar@redhat.com, suzuki.poulose@arm.com, andre.przywara@arm.com, mark.rutland@arm.com, vladimir.murzin@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wangxiongfeng2@huawei.com, wuquanming@huawei.com, huangshaoyu@huawei.com, Leif.Lindholm@linaro.com, nd@arm.com, Igor Mammedov Subject: Re: [PATCH] kvm: pass the virtual SEI syndrome to guest OS Message-ID: <20170329164811-mutt-send-email-mst@kernel.org> References: <58DA3F68.6090901@arm.com> <20170328112328.GA31156@cbox> <20170328115413.GJ23682@e104320-lin> <58DA67BA.8070404@arm.com> <5b7352f4-4965-3ed5-3879-db871797be47@huawei.com> <20170329103658.GQ23682@e104320-lin> <2a427164-9b37-6711-3a56-906634ba7f12@redhat.com> <20170329154539-mutt-send-email-mst@kernel.org> <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 29 Mar 2017 13:54:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 29, 2017 at 03:36:59PM +0200, Laszlo Ersek wrote: > On 03/29/17 14:51, Michael S. Tsirkin wrote: > > On Wed, Mar 29, 2017 at 01:58:29PM +0200, Laszlo Ersek wrote: > >> (8) When QEMU gets SIGBUS from the kernel -- I hope that's going to come > >> through a signalfd -- QEMU can format the CPER right into guest memory, > >> and then inject whatever interrupt (or assert whatever GPIO line) is > >> necessary for notifying the guest. > > > > I think I see a race condition potential - what if guest accesses > > CPER in guest memory while it's being written? > > I'm not entirely sure about the data flow here (these parts of the ACPI > spec are particularly hard to read...), but I thought the OS wouldn't > look until it got a notification. There could be multiple notifications, OS might be looking there because of them. > Or, are you concerned about the next CPER write by QEMU, while the OS is > reading the last one (and maybe the CPER area could wrap around?) > > > > > We can probably use another level of indirection to fix this: > > > > allocate twice the space, add a pointer to where the valid > > table is located and update that after writing CPER completely. > > The pointer can be written atomically but also needs to > > be read atomically, so I suspect it should be a single byte > > as we don't know how are OSPMs implementing this. > > > > A-B-A problem? (Is that usually solved with a cookie or a wider > generation counter? But that would again require wider atomics.) > > I do wonder though how this is handled on physical hardware. Assuming > the hardware error traps to the firmware first (which, on phys hw, is > responsible for depositing the CPER), in that scenario the phys firmware > would face the same issue (i.e., asynchronously interrupting the OS, > which could be reading the previously stored CPER). > > Thanks, > Laszlo ACPI spec seems to specify a set of serialization actions. I'm guessing this is what you need to use to avoid changing guest state while it's reading entries. -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH] kvm: pass the virtual SEI syndrome to guest OS Date: Wed, 29 Mar 2017 16:54:41 +0300 Message-ID: <20170329164811-mutt-send-email-mst@kernel.org> References: <58DA3F68.6090901@arm.com> <20170328112328.GA31156@cbox> <20170328115413.GJ23682@e104320-lin> <58DA67BA.8070404@arm.com> <5b7352f4-4965-3ed5-3879-db871797be47@huawei.com> <20170329103658.GQ23682@e104320-lin> <2a427164-9b37-6711-3a56-906634ba7f12@redhat.com> <20170329154539-mutt-send-email-mst@kernel.org> <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Achin Gupta , gengdongjiu , ard.biesheuvel@linaro.org, edk2-devel@lists.01.org, qemu-devel@nongnu.org, zhaoshenglong@huawei.com, James Morse , Christoffer Dall , xiexiuqi@huawei.com, Marc Zyngier , catalin.marinas@arm.com, will.deacon@arm.com, christoffer.dall@linaro.org, rkrcmar@redhat.com, suzuki.poulose@arm.com, andre.przywara@arm.com, mark.rutland@arm.com, vladimir.murzin@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wangxiongfeng2@huawei.com, wuquanming@huawei.com, huangshaoyu@huawei.com, Leif.Lindholm@linaro.com, nd@arm.com, Igor Mammedov To: Laszlo Ersek Return-path: Content-Disposition: inline In-Reply-To: <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Wed, Mar 29, 2017 at 03:36:59PM +0200, Laszlo Ersek wrote: > On 03/29/17 14:51, Michael S. Tsirkin wrote: > > On Wed, Mar 29, 2017 at 01:58:29PM +0200, Laszlo Ersek wrote: > >> (8) When QEMU gets SIGBUS from the kernel -- I hope that's going to come > >> through a signalfd -- QEMU can format the CPER right into guest memory, > >> and then inject whatever interrupt (or assert whatever GPIO line) is > >> necessary for notifying the guest. > > > > I think I see a race condition potential - what if guest accesses > > CPER in guest memory while it's being written? > > I'm not entirely sure about the data flow here (these parts of the ACPI > spec are particularly hard to read...), but I thought the OS wouldn't > look until it got a notification. There could be multiple notifications, OS might be looking there because of them. > Or, are you concerned about the next CPER write by QEMU, while the OS is > reading the last one (and maybe the CPER area could wrap around?) > > > > > We can probably use another level of indirection to fix this: > > > > allocate twice the space, add a pointer to where the valid > > table is located and update that after writing CPER completely. > > The pointer can be written atomically but also needs to > > be read atomically, so I suspect it should be a single byte > > as we don't know how are OSPMs implementing this. > > > > A-B-A problem? (Is that usually solved with a cookie or a wider > generation counter? But that would again require wider atomics.) > > I do wonder though how this is handled on physical hardware. Assuming > the hardware error traps to the firmware first (which, on phys hw, is > responsible for depositing the CPER), in that scenario the phys firmware > would face the same issue (i.e., asynchronously interrupting the OS, > which could be reading the previously stored CPER). > > Thanks, > Laszlo ACPI spec seems to specify a set of serialization actions. I'm guessing this is what you need to use to avoid changing guest state while it's reading entries. -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctE3n-00078U-RO for qemu-devel@nongnu.org; Wed, 29 Mar 2017 09:54:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctE3k-0001ZJ-Ly for qemu-devel@nongnu.org; Wed, 29 Mar 2017 09:54:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctE3k-0001ZA-D9 for qemu-devel@nongnu.org; Wed, 29 Mar 2017 09:54:48 -0400 Date: Wed, 29 Mar 2017 16:54:41 +0300 From: "Michael S. Tsirkin" Message-ID: <20170329164811-mutt-send-email-mst@kernel.org> References: <58DA3F68.6090901@arm.com> <20170328112328.GA31156@cbox> <20170328115413.GJ23682@e104320-lin> <58DA67BA.8070404@arm.com> <5b7352f4-4965-3ed5-3879-db871797be47@huawei.com> <20170329103658.GQ23682@e104320-lin> <2a427164-9b37-6711-3a56-906634ba7f12@redhat.com> <20170329154539-mutt-send-email-mst@kernel.org> <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> Subject: Re: [Qemu-devel] [PATCH] kvm: pass the virtual SEI syndrome to guest OS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: Achin Gupta , gengdongjiu , ard.biesheuvel@linaro.org, edk2-devel@lists.01.org, qemu-devel@nongnu.org, zhaoshenglong@huawei.com, James Morse , Christoffer Dall , xiexiuqi@huawei.com, Marc Zyngier , catalin.marinas@arm.com, will.deacon@arm.com, christoffer.dall@linaro.org, rkrcmar@redhat.com, suzuki.poulose@arm.com, andre.przywara@arm.com, mark.rutland@arm.com, vladimir.murzin@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wangxiongfeng2@huawei.com, wuquanming@huawei.com, huangshaoyu@huawei.com, Leif.Lindholm@linaro.comnd@arm.com, Igor Mammedov On Wed, Mar 29, 2017 at 03:36:59PM +0200, Laszlo Ersek wrote: > On 03/29/17 14:51, Michael S. Tsirkin wrote: > > On Wed, Mar 29, 2017 at 01:58:29PM +0200, Laszlo Ersek wrote: > >> (8) When QEMU gets SIGBUS from the kernel -- I hope that's going to come > >> through a signalfd -- QEMU can format the CPER right into guest memory, > >> and then inject whatever interrupt (or assert whatever GPIO line) is > >> necessary for notifying the guest. > > > > I think I see a race condition potential - what if guest accesses > > CPER in guest memory while it's being written? > > I'm not entirely sure about the data flow here (these parts of the ACPI > spec are particularly hard to read...), but I thought the OS wouldn't > look until it got a notification. There could be multiple notifications, OS might be looking there because of them. > Or, are you concerned about the next CPER write by QEMU, while the OS is > reading the last one (and maybe the CPER area could wrap around?) > > > > > We can probably use another level of indirection to fix this: > > > > allocate twice the space, add a pointer to where the valid > > table is located and update that after writing CPER completely. > > The pointer can be written atomically but also needs to > > be read atomically, so I suspect it should be a single byte > > as we don't know how are OSPMs implementing this. > > > > A-B-A problem? (Is that usually solved with a cookie or a wider > generation counter? But that would again require wider atomics.) > > I do wonder though how this is handled on physical hardware. Assuming > the hardware error traps to the firmware first (which, on phys hw, is > responsible for depositing the CPER), in that scenario the phys firmware > would face the same issue (i.e., asynchronously interrupting the OS, > which could be reading the previously stored CPER). > > Thanks, > Laszlo ACPI spec seems to specify a set of serialization actions. I'm guessing this is what you need to use to avoid changing guest state while it's reading entries. -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH] kvm: pass the virtual SEI syndrome to guest OS Date: Wed, 29 Mar 2017 16:54:41 +0300 Message-ID: <20170329164811-mutt-send-email-mst@kernel.org> References: <58DA3F68.6090901@arm.com> <20170328112328.GA31156@cbox> <20170328115413.GJ23682@e104320-lin> <58DA67BA.8070404@arm.com> <5b7352f4-4965-3ed5-3879-db871797be47@huawei.com> <20170329103658.GQ23682@e104320-lin> <2a427164-9b37-6711-3a56-906634ba7f12@redhat.com> <20170329154539-mutt-send-email-mst@kernel.org> <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> Sender: linux-kernel-owner@vger.kernel.org To: Laszlo Ersek Cc: Achin Gupta , gengdongjiu , ard.biesheuvel@linaro.org, edk2-devel@lists.01.org, qemu-devel@nongnu.org, zhaoshenglong@huawei.com, James Morse , Christoffer Dall , xiexiuqi@huawei.com, Marc Zyngier , catalin.marinas@arm.com, will.deacon@arm.com, christoffer.dall@linaro.org, rkrcmar@redhat.com, suzuki.poulose@arm.com, andre.przywara@arm.com, mark.rutland@arm.com, vladimir.murzin@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wangxiongfeng2@huawei.com, wuquanming@huawei.com, huangshaoyu@huawei.com, Leif.Lindholm@linaro.comnd@arm.com, Igor Mammedov List-Id: kvmarm@lists.cs.columbia.edu On Wed, Mar 29, 2017 at 03:36:59PM +0200, Laszlo Ersek wrote: > On 03/29/17 14:51, Michael S. Tsirkin wrote: > > On Wed, Mar 29, 2017 at 01:58:29PM +0200, Laszlo Ersek wrote: > >> (8) When QEMU gets SIGBUS from the kernel -- I hope that's going to come > >> through a signalfd -- QEMU can format the CPER right into guest memory, > >> and then inject whatever interrupt (or assert whatever GPIO line) is > >> necessary for notifying the guest. > > > > I think I see a race condition potential - what if guest accesses > > CPER in guest memory while it's being written? > > I'm not entirely sure about the data flow here (these parts of the ACPI > spec are particularly hard to read...), but I thought the OS wouldn't > look until it got a notification. There could be multiple notifications, OS might be looking there because of them. > Or, are you concerned about the next CPER write by QEMU, while the OS is > reading the last one (and maybe the CPER area could wrap around?) > > > > > We can probably use another level of indirection to fix this: > > > > allocate twice the space, add a pointer to where the valid > > table is located and update that after writing CPER completely. > > The pointer can be written atomically but also needs to > > be read atomically, so I suspect it should be a single byte > > as we don't know how are OSPMs implementing this. > > > > A-B-A problem? (Is that usually solved with a cookie or a wider > generation counter? But that would again require wider atomics.) > > I do wonder though how this is handled on physical hardware. Assuming > the hardware error traps to the firmware first (which, on phys hw, is > responsible for depositing the CPER), in that scenario the phys firmware > would face the same issue (i.e., asynchronously interrupting the OS, > which could be reading the previously stored CPER). > > Thanks, > Laszlo ACPI spec seems to specify a set of serialization actions. I'm guessing this is what you need to use to avoid changing guest state while it's reading entries. -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 From: mst@redhat.com (Michael S. Tsirkin) Date: Wed, 29 Mar 2017 16:54:41 +0300 Subject: [PATCH] kvm: pass the virtual SEI syndrome to guest OS In-Reply-To: <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> References: <58DA3F68.6090901@arm.com> <20170328112328.GA31156@cbox> <20170328115413.GJ23682@e104320-lin> <58DA67BA.8070404@arm.com> <5b7352f4-4965-3ed5-3879-db871797be47@huawei.com> <20170329103658.GQ23682@e104320-lin> <2a427164-9b37-6711-3a56-906634ba7f12@redhat.com> <20170329154539-mutt-send-email-mst@kernel.org> <756e3032-e619-a70d-3e29-d2797e52fecf@redhat.com> Message-ID: <20170329164811-mutt-send-email-mst@kernel.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, Mar 29, 2017 at 03:36:59PM +0200, Laszlo Ersek wrote: > On 03/29/17 14:51, Michael S. Tsirkin wrote: > > On Wed, Mar 29, 2017 at 01:58:29PM +0200, Laszlo Ersek wrote: > >> (8) When QEMU gets SIGBUS from the kernel -- I hope that's going to come > >> through a signalfd -- QEMU can format the CPER right into guest memory, > >> and then inject whatever interrupt (or assert whatever GPIO line) is > >> necessary for notifying the guest. > > > > I think I see a race condition potential - what if guest accesses > > CPER in guest memory while it's being written? > > I'm not entirely sure about the data flow here (these parts of the ACPI > spec are particularly hard to read...), but I thought the OS wouldn't > look until it got a notification. There could be multiple notifications, OS might be looking there because of them. > Or, are you concerned about the next CPER write by QEMU, while the OS is > reading the last one (and maybe the CPER area could wrap around?) > > > > > We can probably use another level of indirection to fix this: > > > > allocate twice the space, add a pointer to where the valid > > table is located and update that after writing CPER completely. > > The pointer can be written atomically but also needs to > > be read atomically, so I suspect it should be a single byte > > as we don't know how are OSPMs implementing this. > > > > A-B-A problem? (Is that usually solved with a cookie or a wider > generation counter? But that would again require wider atomics.) > > I do wonder though how this is handled on physical hardware. Assuming > the hardware error traps to the firmware first (which, on phys hw, is > responsible for depositing the CPER), in that scenario the phys firmware > would face the same issue (i.e., asynchronously interrupting the OS, > which could be reading the previously stored CPER). > > Thanks, > Laszlo ACPI spec seems to specify a set of serialization actions. I'm guessing this is what you need to use to avoid changing guest state while it's reading entries. -- MST