Re: [PATCH v2] VT-d: Don't assume register-based invalidation is always supported

2021-04-21 Thread Chao Gao
On Wed, Apr 21, 2021 at 11:23:13AM +0200, Jan Beulich wrote: >On 20.04.2021 18:17, Roger Pau Monné wrote: >> On Tue, Apr 20, 2021 at 05:38:51PM +0200, Jan Beulich wrote: >>> On 20.04.2021 17:08, Roger Pau Monné wrote: >>>> On Thu, Apr 02, 2020 at 04:06:06AM +0800, C

Re: [PATCH v2] VT-d: Don't assume register-based invalidation is always supported

2021-04-20 Thread Chao Gao
On Tue, Apr 20, 2021 at 01:38:26PM +0200, Jan Beulich wrote: >On 01.04.2020 22:06, Chao Gao wrote: >> According to Intel VT-d SPEC rev3.3 Section 6.5, Register-based Invalidation >> isn't supported by Intel VT-d version 6 and beyond. >> >> This hardware change impa

[PATCH v2] VT-d: Don't assume register-based invalidation is always supported

2021-04-20 Thread Chao Gao
be disabled through Xen cmdline; and if queued invalidation has to be disabled temporarily in some scenarios, VT-d won't switch to register-based interface but use some dummy functions to catch errors in case there is any invalidation request issued when queued invalidation is disabled. Signed-off-by: Chao

Re: [RFC PATCH] VT-d: Don't assume register-based invalidation is always supported

2021-04-14 Thread Chao Gao
On Wed, Apr 14, 2021 at 12:07:02PM +0200, Jan Beulich wrote: >On 14.04.2021 02:55, Chao Gao wrote: >> According to Intel VT-d SPEC rev3.3 Section 6.5, Register-based Invalidation >> isn't supported by Intel VT-d version 6 and beyond. >> >> This hardware change impa

[RFC PATCH] VT-d: Don't assume register-based invalidation is always supported

2021-04-14 Thread Chao Gao
invalidation has to be disabled temporarily in some scenarios, VT-d won't switch to register-based interface but use some dummy functions to catch errors in case there is any invalidation request issued when queued invalidation is disabled. Signed-off-by: Chao Gao --- I only tested Xen boot with qinval

Re: [Xen-devel] [BUG]Nested virtualization, Xen on KVM, Xen cannot boot up as a guest of KVM

2020-02-25 Thread Chao Gao
On Wed, Feb 26, 2020 at 02:21:25PM +0800, Chen, Farrah wrote: >Description: > >Nested virtualization, take KVM host as L0, create guest on it, install Xen on >guest, then guest cannot boot up from Xen and keep rebooting. > > > >Reproduce steps: >1. Enable KVM nested on host(L0) >rmmod kvm_intel

Re: [Xen-devel] [PATCH] xen: xen-pciback: Reset MSI-X state when exposing a device

2020-01-17 Thread Chao Gao
On Fri, Jan 17, 2020 at 01:57:43PM -0500, Rich Persaud wrote: >On Sep 26, 2019, at 06:17, Pasi Kärkkäinen wrote: >> >> Hello Stanislav, >> >>> On Fri, Sep 13, 2019 at 11:28:20PM +0800, Chao Gao wrote: >>>> On Fri, Sep 13, 2019 at 10:02:24AM +, Spa

Re: [Xen-devel] [PATCH v3 for 4.13] x86/microcode: refuse to load the same revision ucode

2019-11-26 Thread Chao Gao
e provided ucode with the currently cached one > >CC: Jan Beulich >CC: Andrew Cooper >CC: Roger Pau Monné >CC: Chao Gao >CC: Juergen Gross >--- > xen/arch/x86/microcode.c | 19 +++ > xen/arch/x86/microcode_amd.c | 7 +++ > 2 files changed, 2

Re: [Xen-devel] [PATCH v2 for 4.13] x86/microcode: refuse to load the same revision ucode

2019-11-24 Thread Chao Gao
Which actually means that a ucode blob was parsed fine, but no matching >ucode was found. > >Signed-off-by: Sergey Dyasli Reviewed-by: Chao Gao I wonder whether it is better to put the comparison ... >--- >v1 --> v2: >- compare provided ucode with the currently cached one

Re: [Xen-devel] [PATCH v1 for 4.13] x86/microcode: refuse to load the same revision ucode

2019-11-22 Thread Chao Gao
On Fri, Nov 22, 2019 at 12:19:41PM +0100, Jan Beulich wrote: >On 22.11.2019 11:52, Sergey Dyasli wrote: >> Currently if a user tries to live-load the same ucode revision that CPU >> already has, he will get a single message in Xen log like: >> >> (XEN) 128 cores are to update their microcode

Re: [Xen-devel] [PATCH v1 2/2] microcode: reject late ucode loading if any core is parked

2019-11-21 Thread Chao Gao
On Thu, Nov 21, 2019 at 11:21:13AM +0100, Jan Beulich wrote: >On 21.11.2019 00:05, Chao Gao wrote: >> If a core with all of its thread being parked, late ucode loading >> which currently only loads ucode on online threads would lead to >> differing ucode revisions in t

Re: [Xen-devel] [PATCH v1 1/2] x86/cpu: maintain a parked CPU bitmap

2019-11-21 Thread Chao Gao
On Thu, Nov 21, 2019 at 11:02:10AM +0100, Jan Beulich wrote: >On 21.11.2019 10:47, Julien Grall wrote: >> On 20/11/2019 23:05, Chao Gao wrote: >>> --- a/xen/arch/arm/smpboot.c >>> +++ b/xen/arch/arm/smpboot.c >>> @@ -39,6 +39,7 @@ >>> cpumask_t cp

[Xen-devel] [PATCH v1 1/2] x86/cpu: maintain a parked CPU bitmap

2019-11-20 Thread Chao Gao
It helps to distinguish parked CPUs from those are really offlined or hot-added. We need to know the parked CPUs in order to do a special check against them to ensure that all CPUs, except those are really offlined or hot-added, have the same ucode version. Signed-off-by: Chao Gao --- Note

[Xen-devel] [PATCH v1 2/2] microcode: reject late ucode loading if any core is parked

2019-11-20 Thread Chao Gao
to reduce the number of comparison. Signed-off-by: Chao Gao --- Changes: - traverse the new parked cpu bitmap to find a parked core. It avoids access uninitialized cpu_data of a hot-added CPU. - use bitmap_empty() rather than find_first_bit() to check whether a bitmap is empty. --- xen/arch

Re: [Xen-devel] [PATCH 2/2] libxl_pci: Fix guest shutdown with PCI PT attached

2019-10-15 Thread Chao Gao
On Tue, Oct 15, 2019 at 06:59:37PM +0200, Sander Eikelenboom wrote: >On 14/10/2019 17:03, Chao Gao wrote: >> On Thu, Oct 10, 2019 at 06:13:43PM +0200, Sander Eikelenboom wrote: >>> On 01/10/2019 12:35, Anthony PERARD wrote: >>>> Rewrite of the commit message: &g

Re: [Xen-devel] [PATCH 2/2] libxl_pci: Fix guest shutdown with PCI PT attached

2019-10-14 Thread Chao Gao
the IOMMU code logs is >quite large: > >xen-4.12.0 > Setup: 7.452 s > Tear-down: 7.626 s > >xen-unstable-ee7170822f1fc209f33feb47b268bab35541351d > Setup: 7.468 s > Tear-down: 50.239 s > >Bisection turned up: > commit c4b1ef0f8

Re: [Xen-devel] [PATCH v2] pci: clear {host/guest}_maskall field on assign

2019-10-09 Thread Chao Gao
to reset such field by enabling and disabling MSIX, which is not >intended. > >Signed-off-by: Roger Pau Monné >--- >Cc: Chao Gao >Cc: "Spassov, Stanislav" >Cc: Pasi Kärkkäinen >--- >Chao, Stanislav, can you please check if this patch fixes your >issu

Re: [Xen-devel] [PATCH] pci: clear host_maskall field on assign

2019-10-08 Thread Chao Gao
On Mon, Oct 07, 2019 at 09:38:48AM +0200, Jan Beulich wrote: >On 05.10.2019 01:58, Chao Gao wrote: >> On Wed, Oct 02, 2019 at 12:49:35PM +0200, Roger Pau Monne wrote: >>> The current implementation of host_maskall makes it sticky across >>> assign and deassign calls, wh

Re: [Xen-devel] [PATCH] pci: clear host_maskall field on assign

2019-10-04 Thread Chao Gao
k fields, like guest_masked or the entry maskbit >are already reset when the msix capability is initialized. Also note >that doing the reset of host_maskall there would allow the guest to >reset such field by enabling and disabling MSIX, which is not >intended. > >Signed-off-by: Roger

Re: [Xen-devel] [PATCH for Xen 4.13] x86/msi: Don't panic if msix capability is missing

2019-09-30 Thread Chao Gao
On Mon, Sep 30, 2019 at 11:18:05AM +0200, Jan Beulich wrote: >On 29.09.2019 23:24, Chao Gao wrote: >> --- a/xen/arch/x86/msi.c >> +++ b/xen/arch/x86/msi.c >> @@ -1265,7 +1265,13 @@ int pci_msi_conf_write_intercept(struct pci_dev >> *pdev, unsigned int reg, >

Re: [Xen-devel] [PATCH for Xen 4.13] x86/msi: Don't panic if msix capability is missing

2019-09-30 Thread Chao Gao
On Mon, Sep 30, 2019 at 11:09:58AM +0200, Roger Pau Monné wrote: >On Mon, Sep 30, 2019 at 05:24:31AM +0800, Chao Gao wrote: >> Current, Xen isn't aware of device reset (initiated by dom0). Xen may >> access the device while device cannot respond to config requests >> normall

Re: [Xen-devel] [PATCH v11 7/7] microcode: reject late ucode loading if any core is parked

2019-09-30 Thread Chao Gao
On Fri, Sep 27, 2019 at 01:19:16PM +0200, Jan Beulich wrote: >On 26.09.2019 15:53, Chao Gao wrote: >> If a core with all of its thread being parked, late ucode loading >> which currently only loads ucode on online threads would lead to >> differing ucode revisions in t

[Xen-devel] [PATCH for Xen 4.13] x86/msi: Don't panic if msix capability is missing

2019-09-29 Thread Chao Gao
to pci_dev_wait() in linux kernel for more detail). Here, don't assume msix capability is always visible and return -EAGAIN to the caller. Signed-off-by: Chao Gao --- I didn't find a way to trigger the assertion in normal usages. It is found by an internal test: echo 1 to /sys/bus/pci//reset when the device

[Xen-devel] [PATCH v12] microcode: rendezvous CPUs in NMI handler and load ucode

2019-09-27 Thread Chao Gao
on the control thread first to mitigate this issue. Signed-off-by: Sergey Dyasli Signed-off-by: Chao Gao --- Note: I plan to finish remaining patches (like handling parked CPU, BDF90 and WBINVD, IMO, not important as this one) in RCs. So this v12 only has one patch. Changes in v12: - take care that self

Re: [Xen-devel] [PATCH v11 6/7] microcode: rendezvous CPUs in NMI handler and load ucode

2019-09-27 Thread Chao Gao
On Fri, Sep 27, 2019 at 03:55:00PM +0200, Jan Beulich wrote: >On 27.09.2019 15:53, Chao Gao wrote: >> On Fri, Sep 27, 2019 at 12:19:22PM +0200, Jan Beulich wrote: >>> On 26.09.2019 15:53, Chao Gao wrote: >>>> @@ -420,14 +498,23 @@ static int control_thread_fn(cons

Re: [Xen-devel] [PATCH v11 6/7] microcode: rendezvous CPUs in NMI handler and load ucode

2019-09-27 Thread Chao Gao
On Fri, Sep 27, 2019 at 12:19:22PM +0200, Jan Beulich wrote: >On 26.09.2019 15:53, Chao Gao wrote: >> @@ -105,23 +110,42 @@ void __init microcode_set_module(unsigned int idx) >> } >> >> /* >> - * The format is '[|scan]'. Both options are optional. >>

[Xen-devel] [PATCH v11 5/7] microcode: remove microcode_update_lock

2019-09-26 Thread Chao Gao
of logical threads. 3.get/put_cpu_bitmaps() prevents the concurrency of CPU-hotplug and late microcode update. Note that printk in apply_microcode() and svm_host_osvm_init() (for AMD only) are still processed sequentially. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v7

[Xen-devel] [PATCH v11 7/7] microcode: reject late ucode loading if any core is parked

2019-09-26 Thread Chao Gao
to reduce the number of comparison. Signed-off-by: Chao Gao --- Alternatively, we can mask the thread id off apicid and use it as the unique core id. It needs to introduce new field in cpuinfo_x86 to record the mask for thread id. So I don't take this way. --- xen/arch/x86/microcode.c| 75

[Xen-devel] [PATCH v11 6/7] microcode: rendezvous CPUs in NMI handler and load ucode

2019-09-26 Thread Chao Gao
). The side effect is control thread might be handling an NMI and interacting with the old ucode not in a controlled way while other threads are loading ucode. Update ucode on the control thread first to mitigate this issue. Signed-off-by: Sergey Dyasli Signed-off-by: Chao Gao --- Changes in v11

[Xen-devel] [PATCH v11 2/7] microcode: unify ucode loading during system bootup and resuming

2019-09-26 Thread Chao Gao
ion), start_update is always true and so remove this parameter. There is a functional change: ->start_update is called on BSP and ->end_update_percpu is called during system resuming. They are not invoked by previous microcode_resume_cpu(). Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Chang

[Xen-devel] [PATCH v11 4/7] x86/microcode: Synchronize late microcode loading

2019-09-26 Thread Chao Gao
cores and serialize the microcode update on them by doing it one-by-one to make the late update process as reliable as possible and avoid potential issues caused by the microcode update. Signed-off-by: Chao Gao Tested-by: Chao Gao [linux commit: a5321aec6412b20b5ad15db2d6b916c05349dbff] [linux commit

[Xen-devel] [PATCH v11 0/7] improve late microcode loading

2019-09-26 Thread Chao Gao
mix with current cpu. Changes in version 5: - support parallel microcode updates for all cores (see patch 8) - Address Roger's comments on the last version. Chao Gao (7): microcode: split out apply_microcode() from cpu_request_microcode() microcode: unify ucode loading during system boo

[Xen-devel] [PATCH v11 3/7] microcode: reduce memory allocation and copy when creating a patch

2019-09-26 Thread Chao Gao
, buffers like mc_amd, equiv_cpu_table (on AMD side), and mc (on Intel side) can be reused. microcode_patch now is allocated after it is sure that there is a matching ucode. Signed-off-by: Chao Gao Reviewed-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Changes in v11: - correct parameter type

[Xen-devel] [PATCH v11 1/7] microcode: split out apply_microcode() from cpu_request_microcode()

2019-09-26 Thread Chao Gao
be stored into the patch cache. Note that calling ->apply_microcode() itself doesn't require any lock being held. But the parameter passed to it may be protected by some locks. E.g. microcode_update_cpu() acquires microcode_mutex to avoid microcode_cache being updated by others. Signed-off-by: C

Re: [Xen-devel] [PATCH RFC] pass-through: sync pir to irr after msix vector been updated

2019-09-23 Thread Chao Gao
On Wed, Sep 18, 2019 at 02:16:13PM -0700, Joe Jin wrote: >On 9/16/19 11:48 PM, Jan Beulich wrote: >> On 17.09.2019 00:20, Joe Jin wrote: >>> On 9/16/19 1:01 AM, Jan Beulich wrote: On 13.09.2019 18:38, Joe Jin wrote: > On 9/13/19 12:14 AM, Jan Beulich wrote: >> On 12.09.2019 20:03, Joe

Re: [Xen-devel] [PATCH v10 15/16] microcode: disable late loading if CPUs are affected by BDF90

2019-09-17 Thread Chao Gao
On Fri, Sep 13, 2019 at 11:22:59AM +0200, Jan Beulich wrote: >On 12.09.2019 09:22, Chao Gao wrote: >> @@ -283,6 +284,27 @@ static enum microcode_match_result compare_patch( >> : OLD_UCODE; >> } >> >>

Re: [Xen-devel] [PATCH v10 00/16] improve late microcode loading

2019-09-17 Thread Chao Gao
On Fri, Sep 13, 2019 at 10:47:36AM +0200, Jan Beulich wrote: >On 12.09.2019 09:22, Chao Gao wrote: >> This series includes below changes: >> 1. Patch 1-11: introduce a global microcode cache and some cleanup >> 2. Patch 12: synchronize late microcode loading >> 3.

Re: [Xen-devel] [PATCH v10 14/16] microcode: rendezvous CPUs in NMI handler and load ucode

2019-09-15 Thread Chao Gao
On Fri, Sep 13, 2019 at 11:14:59AM +0200, Jan Beulich wrote: >On 12.09.2019 09:22, Chao Gao wrote: >> When one core is loading ucode, handling NMI on sibling threads or >> on other cores in the system might be problematic. By rendezvousing >> all CPUs in NMI handler, it pr

Re: [Xen-devel] [PATCH] xen: xen-pciback: Reset MSI-X state when exposing a device

2019-09-13 Thread Chao Gao
On Fri, Sep 13, 2019 at 10:02:24AM +, Spassov, Stanislav wrote: >On Thu, Dec 13, 2018 at 07:54, Chao Gao wrote: >>On Thu, Dec 13, 2018 at 12:54:52AM -0700, Jan Beulich wrote: >>>>>> On 13.12.18 at 04:46, wrote: >>>> On Wed, Dec 12, 2018

Re: [Xen-devel] [PATCH v10 01/16] microcode/intel: extend microcode_update_match()

2019-09-13 Thread Chao Gao
On Fri, Sep 13, 2019 at 08:50:59AM +0200, Jan Beulich wrote: >On 12.09.2019 12:24, Jan Beulich wrote: >> On 12.09.2019 09:22, Chao Gao wrote: >>> --- a/xen/arch/x86/microcode_intel.c >>> +++ b/xen/arch/x86/microcode_intel.c >>> @@ -134,21 +134,11 @@ static int c

Re: [Xen-devel] [PATCH v10 12/16] x86/microcode: Synchronize late microcode loading

2019-09-13 Thread Chao Gao
On Thu, Sep 12, 2019 at 05:32:22PM +0200, Jan Beulich wrote: >On 12.09.2019 09:22, Chao Gao wrote: >> @@ -264,38 +336,158 @@ static int microcode_update_cpu(const struct >> microcode_patch *patch) >> return err; >> } >> >> -static long do_microc

Re: [Xen-devel] [PATCH v10 09/16] microcode: split out apply_microcode() from cpu_request_microcode()

2019-09-13 Thread Chao Gao
On Thu, Sep 12, 2019 at 04:07:16PM +0200, Jan Beulich wrote: >On 12.09.2019 09:22, Chao Gao wrote: >> @@ -249,49 +249,80 @@ bool microcode_update_cache(struct microcode_patch >> *patch) >> return true; >> } >> >> -static int microcode_

[Xen-devel] [PATCH v10 14/16] microcode: rendezvous CPUs in NMI handler and load ucode

2019-09-12 Thread Chao Gao
. Primary threads call in and load ucode in NMI handler. Secondary threads wait for the completion of ucode loading on all CPU cores. An option is introduced to disable this behavior. Signed-off-by: Chao Gao Signed-off-by: Sergey Dyasli --- Changes in v10: - rewrite based on Sergey's idea and patch

[Xen-devel] [PATCH v10 00/16] improve late microcode loading

2019-09-12 Thread Chao Gao
cpu. Changes in version 5: - support parallel microcode updates for all cores (see patch 8) - Address Roger's comments on the last version. Chao Gao (16): microcode/intel: extend microcode_update_match() microcode/amd: distinguish old and mismatched ucode in microcode_fits() microc

[Xen-devel] [PATCH v10 08/16] microcode: pass a patch pointer to apply_microcode()

2019-09-12 Thread Chao Gao
apply_microcode()'s always loading the cached ucode patch forces a patch to be stored before being loaded. Make apply_microcode() accept a patch pointer to remove the limitation so that a patch can be stored after a successful loading. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- xen

[Xen-devel] [PATCH v10 09/16] microcode: split out apply_microcode() from cpu_request_microcode()

2019-09-12 Thread Chao Gao
be stored into the patch cache. Signed-off-by: Chao Gao Reviewed-by: Roger Pau Monné --- Changes in v10: - make microcode_update_cache static - raise an error if loading ucode failed with -EIO - ensure end_update_percpu() is called following a successful call of start_update() Changes in v9

[Xen-devel] [PATCH v10 16/16] microcode/intel: writeback and invalidate cache conditionally

2019-09-12 Thread Chao Gao
It is needed to mitigate some issues on this specific Broadwell CPU. Signed-off-by: Chao Gao --- xen/arch/x86/microcode_intel.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/xen/arch/x86/microcode_intel.c b/xen/arch/x86/microcode_intel.c index bcef668..4e5e7f9

[Xen-devel] [PATCH v10 10/16] microcode: unify ucode loading during system bootup and resuming

2019-09-12 Thread Chao Gao
ion), start_update is always true and so remove this parameter. There is a functional change: ->start_update is called on BSP and ->end_update_percpu is called during system resuming. They are not invoked by previous microcode_resume_cpu(). Signed-off-by: Chao Gao --- Changes in v10: - call ->

[Xen-devel] [PATCH v10 05/16] microcode: remove struct ucode_cpu_info

2019-09-12 Thread Chao Gao
removed. It was used to free the "mc" field to avoid memory leak. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v9: - rebase and fix conflict Changes in v8: - split microcode_resume_cpu() cleanup to a separate patch. Changes in v6: - remove the whole struct ucod

[Xen-devel] [PATCH v10 13/16] microcode: remove microcode_update_lock

2019-09-12 Thread Chao Gao
of logical threads. 3.get/put_cpu_bitmaps() prevents the concurrency of CPU-hotplug and late microcode update. Note that printk in apply_microcode() and svm_host_osvm_init() (for AMD only) are still processed sequentially. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v7

[Xen-devel] [PATCH v10 02/16] microcode/amd: distinguish old and mismatched ucode in microcode_fits()

2019-09-12 Thread Chao Gao
is made in this patch. But following patch would handle "old ucode" and "mismatched ucode" separately. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v8: - new --- xen/arch/x86/microcode_amd.c | 18 +- 1 file changed, 9 insertions(+), 9 dele

[Xen-devel] [PATCH v10 03/16] microcode: introduce a global cache of ucode patch

2019-09-12 Thread Chao Gao
ve it completely in the following patches. We copy everything to create the new cache blob to avoid reusing some buffers previously allocated for the old per-cpu cache. It is not so efficient, but it is already corrected by a patch later in this series. Signed-off-by: Chao Gao Reviewed-by:

[Xen-devel] [PATCH v10 15/16] microcode: disable late loading if CPUs are affected by BDF90

2019-09-12 Thread Chao Gao
It ports the implementation of is_blacklisted() in linux kernel to Xen. Late loading may cause system hang if CPUs are affected by BDF90. Check against BDF90 before performing a late loading. Signed-off-by: Chao Gao --- xen/arch/x86/microcode.c| 6 ++ xen/arch/x86

[Xen-devel] [PATCH v10 07/16] microcode/amd: call svm_host_osvw_init() in common code

2019-09-12 Thread Chao Gao
of loading an update. Signed-off-by: Chao Gao Reviewed-by: Roger Pau Monné --- Changes in v10: - rename end_update to end_update_percpu. - use #ifdef rather than #if and frame the implementation with Changes in v9: - call .end_update in early loading path - on AMD side, initialize .{start,end

[Xen-devel] [PATCH v10 11/16] microcode: reduce memory allocation and copy when creating a patch

2019-09-12 Thread Chao Gao
, buffers like mc_amd, equiv_cpu_table (on AMD side), and mc (on Intel side) can be reused. microcode_patch now is allocated after it is sure that there is a matching ucode. Signed-off-by: Chao Gao Reviewed-by: Roger Pau Monné --- Changes in v10: - avoid unnecessary type casting * introduce

[Xen-devel] [PATCH v10 04/16] microcode: clean up microcode_resume_cpu

2019-09-12 Thread Chao Gao
a lot and only a single ucode is cached. a single invocation of ->apply_microcode() would load the cache and make microcode updated. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- changes in v8: - new - separated from the following patch --- xen/arch/x86/microcode.c|

[Xen-devel] [PATCH v10 01/16] microcode/intel: extend microcode_update_match()

2019-09-12 Thread Chao Gao
of microcode_sanity_check() such that it can be called by microcode_update_match(). Signed-off-by: Chao Gao --- Changes in v10: - Drop RBs - assert that microcode passed to microcode_update_match() would pass sanity check. Constify the parameter of microcode_sanity_check() Changes in v9

[Xen-devel] [PATCH v10 12/16] x86/microcode: Synchronize late microcode loading

2019-09-12 Thread Chao Gao
cores and serialize the microcode update on them by doing it one-by-one to make the late update process as reliable as possible and avoid potential issues caused by the microcode update. Signed-off-by: Chao Gao Tested-by: Chao Gao [linux commit: a5321aec6412b20b5ad15db2d6b916c05349dbff] [linux commit

[Xen-devel] [PATCH v10 06/16] microcode: remove pointless 'cpu' parameter

2019-09-12 Thread Chao Gao
Some callbacks in microcode_ops or related functions take a cpu id parameter. But at current call sites, the cpu id parameter is always equal to current cpu id. Some of them even use an assertion to guarantee this. Remove this redundent 'cpu' parameter. Signed-off-by: Chao Gao Reviewed-by: Jan

Re: [Xen-devel] [ANNOUNCE] Xen 4.13 Development Update

2019-09-11 Thread Chao Gao
CPU topology support (RFC) > - Chao Gao No plan to continue this one due to some reason. Please drop this one. > >* Improve late microcode loading (v9) > - Chao Gao > Working on the v10. I would like to get it merged in 4.13. Thanks Chao __

Re: [Xen-devel] [PATCH v9 15/15] microcode: block #NMI handling when loading an ucode

2019-09-08 Thread Chao Gao
On Fri, Aug 30, 2019 at 02:35:06PM +0800, Chao Gao wrote: >On Thu, Aug 29, 2019 at 02:11:10PM +0200, Jan Beulich wrote: >>On 27.08.2019 06:52, Chao Gao wrote: >>> On Mon, Aug 26, 2019 at 04:07:59PM +0800, Chao Gao wrote: >>>> On Fri, Aug 23, 2019 at 09:46:3

Re: [Xen-devel] [RFC Patch] xen/pt: Emulate FLR capability

2019-09-06 Thread Chao Gao
On Thu, Aug 29, 2019 at 12:21:11PM +0200, Roger Pau Monné wrote: >On Thu, Aug 29, 2019 at 05:02:27PM +0800, Chao Gao wrote: >> Currently, for a HVM on Xen, no reset method is virtualized. So in a VM's >> perspective, assigned devices cannot be reset. But some devices rely

Re: [Xen-devel] [Xen-unstable] boot crash while loading AMD microcode due to commit "microcode/amd: fix memory leak"

2019-08-30 Thread Chao Gao
On Fri, Aug 30, 2019 at 09:49:04AM +0200, Jan Beulich wrote: >On 30.08.2019 04:09, Chao Gao wrote: >> On Fri, Aug 30, 2019 at 01:04:54AM +0200, Sander Eikelenboom wrote: >>> L.S., >>> >>> While testing xen-unstable, my AMD system crashes during ear

Re: [Xen-devel] [PATCH v9 15/15] microcode: block #NMI handling when loading an ucode

2019-08-30 Thread Chao Gao
On Thu, Aug 29, 2019 at 02:11:10PM +0200, Jan Beulich wrote: >On 27.08.2019 06:52, Chao Gao wrote: >> On Mon, Aug 26, 2019 at 04:07:59PM +0800, Chao Gao wrote: >>> On Fri, Aug 23, 2019 at 09:46:37AM +0100, Sergey Dyasli wrote: >>>> On 19/08/2019 02:25, Chao Ga

Re: [Xen-devel] [PATCH v9 15/15] microcode: block #NMI handling when loading an ucode

2019-08-30 Thread Chao Gao
On Thu, Aug 29, 2019 at 02:22:47PM +0200, Jan Beulich wrote: >On 19.08.2019 03:25, Chao Gao wrote: >> @@ -481,12 +478,28 @@ static int do_microcode_update(void *patch) >> return ret; >> } >> >> +static int microcode_nmi_callback(const st

Re: [Xen-devel] [PATCH v9 13/15] x86/microcode: Synchronize late microcode loading

2019-08-29 Thread Chao Gao
On Thu, Aug 29, 2019 at 02:06:39PM +0200, Jan Beulich wrote: >On 19.08.2019 03:25, Chao Gao wrote: >> + >> +static int master_thread_fn(const struct microcode_patch *patch) >> +{ >> +unsigned int cpu = smp_processor_id(); >> +int ret = 0; &

Re: [Xen-devel] [PATCH v9 10/15] microcode: split out apply_microcode() from cpu_request_microcode()

2019-08-29 Thread Chao Gao
On Thu, Aug 29, 2019 at 12:06:28PM +0200, Jan Beulich wrote: >On 22.08.2019 15:59, Roger Pau Monné wrote: >> Seeing how this works I'm not sure what's the best option here. As >> updating will be attempted on other CPUs, I'm not sure if it's OK to >> return an error if the update succeed on some

Re: [Xen-devel] [Xen-unstable] boot crash while loading AMD microcode due to commit "microcode/amd: fix memory leak"

2019-08-29 Thread Chao Gao
On Fri, Aug 30, 2019 at 01:04:54AM +0200, Sander Eikelenboom wrote: >L.S., > >While testing xen-unstable, my AMD system crashes during early boot while >loading microcode with an "Early fatal page fault". >Reverting commit de45e3ff37bb1602796054afabfa626ea5661c45 "microcode/amd: fix >memory

Re: [Xen-devel] [RFC Patch] xen/pt: Emulate FLR capability

2019-08-29 Thread Chao Gao
On Thu, Aug 29, 2019 at 12:03:44PM +0200, Jan Beulich wrote: >On 29.08.2019 11:02, Chao Gao wrote: >> Currently, for a HVM on Xen, no reset method is virtualized. So in a VM's >> perspective, assigned devices cannot be reset. But some devices rely on PCI >> reset to recove

[Xen-devel] [RFC Patch] xen/pt: Emulate FLR capability

2019-08-29 Thread Chao Gao
guest, deleting emulated registers), then initiate PCI reset through 'reset' knob under the device's sysfs, finally initialize the device again. Signed-off-by: Chao Gao --- Do we need to introduce an attribute, like "permissive" to explicitly enable FLR capability emulation? During

Re: [Xen-devel] [PATCH v9 11/15] microcode: unify loading update during CPU resuming and AP wakeup

2019-08-29 Thread Chao Gao
On Fri, Aug 23, 2019 at 11:09:07AM +0200, Roger Pau Monné wrote: >On Fri, Aug 23, 2019 at 12:44:34AM +0800, Chao Gao wrote: >> On Thu, Aug 22, 2019 at 04:10:46PM +0200, Roger Pau Monné wrote: >> >On Mon, Aug 19, 2019 at 09:25:24AM +0800, Chao Gao wrote: >> >> Bot

Re: [Xen-devel] [PATCH v9 01/15] microcode/intel: extend microcode_update_match()

2019-08-29 Thread Chao Gao
On Wed, Aug 28, 2019 at 05:12:34PM +0200, Jan Beulich wrote: >On 19.08.2019 03:25, Chao Gao wrote: >> to a more generic function. So that it can be used alone to check >> an update against the CPU signature and current update revision. >> >> Note that enum microcod

Re: [Xen-devel] [PATCH v9 15/15] microcode: block #NMI handling when loading an ucode

2019-08-26 Thread Chao Gao
On Mon, Aug 26, 2019 at 04:07:59PM +0800, Chao Gao wrote: >On Fri, Aug 23, 2019 at 09:46:37AM +0100, Sergey Dyasli wrote: >>On 19/08/2019 02:25, Chao Gao wrote: >>> register an nmi callback. And this callback does busy-loop on threads >>> which are waiting for loading

Re: [Xen-devel] Reset pass-thru devices in a VM

2019-08-26 Thread Chao Gao
On Tue, Aug 27, 2019 at 12:17:28AM +0300, Pasi Kärkkäinen wrote: >Hi Chao, > >On Fri, Aug 09, 2019 at 04:38:33PM +0800, Chao Gao wrote: >> Hi everyone, >> >> I have a device which only supports secondary bus reset. After being >> assigned to a VM, it would be plac

Re: [Xen-devel] [PATCH v9 15/15] microcode: block #NMI handling when loading an ucode

2019-08-26 Thread Chao Gao
On Fri, Aug 23, 2019 at 09:46:37AM +0100, Sergey Dyasli wrote: >On 19/08/2019 02:25, Chao Gao wrote: >> register an nmi callback. And this callback does busy-loop on threads >> which are waiting for loading completion. Control threads send NMI to >> slave threads to prevent

Re: [Xen-devel] [PATCH v9 12/15] microcode: reduce memory allocation and copy when creating a patch

2019-08-26 Thread Chao Gao
On Fri, Aug 23, 2019 at 10:11:21AM +0200, Roger Pau Monné wrote: >On Mon, Aug 19, 2019 at 09:25:25AM +0800, Chao Gao wrote: >> To create a microcode patch from a vendor-specific update, >> allocate_microcode_patch() copied everything from the update. >> It is not efficient.

Re: [Xen-devel] [PATCH v9 11/15] microcode: unify loading update during CPU resuming and AP wakeup

2019-08-22 Thread Chao Gao
On Thu, Aug 22, 2019 at 04:10:46PM +0200, Roger Pau Monné wrote: >On Mon, Aug 19, 2019 at 09:25:24AM +0800, Chao Gao wrote: >> Both are loading the cached patch. Since APs call the unified function, >> microcode_update_one(), during wakeup, the 'start_update' parameter >>

Re: [Xen-devel] [PATCH v9 00/15] improve late microcode loading

2019-08-22 Thread Chao Gao
On Thu, Aug 22, 2019 at 08:51:43AM +0100, Sergey Dyasli wrote: >Hi Chao, > >On 19/08/2019 02:25, Chao Gao wrote: >> Previous change log: >> Changes in version 8: >> - block #NMI handling during microcode loading (Patch 16) >> - Don't assume that all CPUs in th

Re: [Xen-devel] [PATCH v9 13/15] x86/microcode: Synchronize late microcode loading

2019-08-19 Thread Chao Gao
On Mon, Aug 19, 2019 at 11:27:36AM +0100, Sergey Dyasli wrote: >> +static int master_thread_fn(const struct microcode_patch *patch) >> +{ >> +unsigned int cpu = smp_processor_id(); >> +int ret = 0; >> + >> +while ( loading_state != LOADING_CALLIN ) >> +cpu_relax(); >> + >> +

[Xen-devel] [PATCH v9 14/15] microcode: remove microcode_update_lock

2019-08-18 Thread Chao Gao
of logical threads. 3.get/put_cpu_bitmaps() prevents the concurrency of CPU-hotplug and late microcode update. Note that printk in apply_microcode() and svm_host_osvm_init() (for AMD only) are still processed sequentially. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v7

[Xen-devel] [PATCH v9 15/15] microcode: block #NMI handling when loading an ucode

2019-08-18 Thread Chao Gao
register an nmi callback. And this callback does busy-loop on threads which are waiting for loading completion. Control threads send NMI to slave threads to prevent NMI acceptance during ucode loading. Signed-off-by: Chao Gao --- Changes in v9: - control threads send NMI to all other threads

[Xen-devel] [PATCH v9 13/15] x86/microcode: Synchronize late microcode loading

2019-08-18 Thread Chao Gao
cores and serialize the microcode update on them by doing it one-by-one to make the late update process as reliable as possible and avoid potential issues caused by the microcode update. Signed-off-by: Chao Gao Tested-by: Chao Gao [linux commit: a5321aec6412b20b5ad15db2d6b916c05349dbff] [linux commit

[Xen-devel] [PATCH v9 04/15] microcode: introduce a global cache of ucode patch

2019-08-18 Thread Chao Gao
going to remove it completely in the following patches. We copy everything to create the new cache blob to avoid reusing some buffers previously allocated for the old per-cpu cache. It is not so efficient, but it is already corrected by a patch later in this series. Signed-off-by: Chao Gao -

[Xen-devel] [PATCH v9 01/15] microcode/intel: extend microcode_update_match()

2019-08-18 Thread Chao Gao
to a more generic function. So that it can be used alone to check an update against the CPU signature and current update revision. Note that enum microcode_match_result will be used in common code (aka microcode.c), it has been placed in the common header. Signed-off-by: Chao Gao Reviewed

[Xen-devel] [PATCH v9 02/15] microcode/amd: fix memory leak

2019-08-18 Thread Chao Gao
Two buffers, '->equiv_cpu_table' and '->mpb', inside 'mc_amd' might be allocated and in the error-handing path they are not freed properly. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v9: - use xzalloc() to get rid of explicitly initializing some fields to

[Xen-devel] [PATCH v9 06/15] microcode: remove struct ucode_cpu_info

2019-08-18 Thread Chao Gao
removed. It was used to free the "mc" field to avoid memory leak. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v9: - rebase and fix conflict Changes in v8: - split microcode_resume_cpu() cleanup to a separate patch. Changes in v6: - remove the whole struct ucod

[Xen-devel] [PATCH v9 03/15] microcode/amd: distinguish old and mismatched ucode in microcode_fits()

2019-08-18 Thread Chao Gao
is made in this patch. But following patch would handle "old ucode" and "mismatched ucode" separately. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- Changes in v8: - new --- xen/arch/x86/microcode_amd.c | 18 +- 1 file changed, 9 insertions(+), 9 dele

[Xen-devel] [PATCH v9 05/15] microcode: clean up microcode_resume_cpu

2019-08-18 Thread Chao Gao
a lot and only a single ucode is cached. a single invocation of ->apply_microcode() would load the cache and make microcode updated. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- changes in v8: - new - separated from the following patch --- xen/arch/x86/microcode.c|

[Xen-devel] [PATCH v9 11/15] microcode: unify loading update during CPU resuming and AP wakeup

2019-08-18 Thread Chao Gao
Both are loading the cached patch. Since APs call the unified function, microcode_update_one(), during wakeup, the 'start_update' parameter which originally used to distinguish BSP and APs is redundant. So remove this parameter. Signed-off-by: Chao Gao --- Note that here is a functional change

[Xen-devel] [PATCH v9 10/15] microcode: split out apply_microcode() from cpu_request_microcode()

2019-08-18 Thread Chao Gao
be stored into the patch cache. Signed-off-by: Chao Gao --- Changes in v9: - remove the calling of ->compare_patch in microcode_update_cpu(). - drop "microcode_" prefix for static function - microcode_parse_blob(). - rebase and fix conflict Changes in v8: - divide the original pat

[Xen-devel] [PATCH v9 08/15] microcode/amd: call svm_host_osvw_init() in common code

2019-08-18 Thread Chao Gao
an update. Signed-off-by: Chao Gao --- Changes in v9: - call .end_update in early loading path - on AMD side, initialize .{start,end}_update only if "CONFIG_HVM" is true. --- xen/arch/x86/microcode.c| 10 +- xen/arch/x86/microcode_amd.c| 23 ++

[Xen-devel] [PATCH v9 00/15] improve late microcode loading

2019-08-18 Thread Chao Gao
an ucode patch only if its supported CPU is allowed to mix with current cpu. Changes in version 5: - support parallel microcode updates for all cores (see patch 8) - Address Roger's comments on the last version. Chao Gao (15): microcode/intel: extend microcode_update_match() microcode/amd

[Xen-devel] [PATCH v9 09/15] microcode: pass a patch pointer to apply_microcode()

2019-08-18 Thread Chao Gao
apply_microcode()'s always loading the cached ucode patch forces a patch to be stored before being loading. Make apply_microcode() accept a patch pointer to remove the limitation so that a patch can be stored after a successful loading. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- xen

[Xen-devel] [PATCH v9 07/15] microcode: remove pointless 'cpu' parameter

2019-08-18 Thread Chao Gao
Some callbacks in microcode_ops or related functions take a cpu id parameter. But at current call sites, the cpu id parameter is always equal to current cpu id. Some of them even use an assertion to guarantee this. Remove this redundent 'cpu' parameter. Signed-off-by: Chao Gao Reviewed-by: Jan

[Xen-devel] [PATCH v9 12/15] microcode: reduce memory allocation and copy when creating a patch

2019-08-18 Thread Chao Gao
, buffers like mc_amd, equiv_cpu_table (on AMD side), and mc (on Intel side) can be reused. microcode_patch now is allocated after it is sure that there is a matching ucode. Signed-off-by: Chao Gao --- Changes in v9: - new --- xen/arch/x86/microcode_amd.c | 99

Re: [Xen-devel] Reset pass-thru devices in a VM

2019-08-09 Thread Chao Gao
On Fri, Aug 09, 2019 at 03:23:59PM +0200, Jan Beulich wrote: >On 09.08.2019 15:24, Chao Gao wrote: >>On Fri, Aug 09, 2019 at 10:49:32AM +0200, Jan Beulich wrote: >>>On 09.08.2019 10:38, Chao Gao wrote: >>>>Alternatively, emulating FLR (Function Level Reset) >&g

Re: [Xen-devel] Reset pass-thru devices in a VM

2019-08-09 Thread Chao Gao
On Fri, Aug 09, 2019 at 02:42:09PM +0200, Roger Pau Monné wrote: >On Fri, Aug 09, 2019 at 04:38:33PM +0800, Chao Gao wrote: >> Hi everyone, >> >> I have a device which only supports secondary bus reset. After being >> assigned to a VM, it would be placed under host b

Re: [Xen-devel] Reset pass-thru devices in a VM

2019-08-09 Thread Chao Gao
On Fri, Aug 09, 2019 at 10:49:32AM +0200, Jan Beulich wrote: >On 09.08.2019 10:38, Chao Gao wrote: >>I have a device which only supports secondary bus reset. After being >>assigned to a VM, it would be placed under host bridge. For devices >>under host bridge, secondary bus re

[Xen-devel] Reset pass-thru devices in a VM

2019-08-09 Thread Chao Gao
Hi everyone, I have a device which only supports secondary bus reset. After being assigned to a VM, it would be placed under host bridge. For devices under host bridge, secondary bus reset is not applicable. Thus, a VM has no way to reset this device. This device's usage would be limited without

Re: [Xen-devel] [PATCH v8 16/16] microcode: block #NMI handling when loading an ucode

2019-08-07 Thread Chao Gao
On Mon, Aug 05, 2019 at 12:11:01PM +, Jan Beulich wrote: >On 01.08.2019 12:22, Chao Gao wrote: >> @@ -439,12 +440,37 @@ static int do_microcode_update(void *patch) >> return ret; >> } >> >> +static int microcode_nmi_callback(const st

  1   2   3   4   >