Re: [PATCH] mm/hugetlb: fix error code in hugetlbfs_alloc_inode

2012-07-09 Thread Gavin Shan
On Tue, Jul 10, 2012 at 09:03:04AM +0800, Wanpeng Li wrote: >From: Wanpeng Li > >When kmem_cache_alloc fails alloc slab object from >hugetlbfs_inode_cachep, return -ENOMEM in usual. But >hugetlbfs_alloc_inode implementation has inconsitency >with it and returns NULL. Fix it to return -ENOMEM. > >S

Re: [PATCH net-next] net/ncsi: avoid maybe-uninitialized warning

2016-07-21 Thread Gavin Shan
he variable >was unused or not. > >This rearranges the code in a way that makes it obvious to gcc that old_state >is always initialized at the time of use, functionally this should not >change anything. > >Signed-off-by: Arnd Bergmann Acked-by: Gavin Shan

[PATCH] virtio_ring: Fix the stale index in available ring

2024-03-14 Thread Gavin Shan
architectures, but performance loss is expected. Cc: sta...@vger.kernel.org Reported-by: Yihuang Yu Signed-off-by: Gavin Shan --- drivers/virtio/virtio_ring.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c in

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-14 Thread Gavin Shan
On 3/14/24 18:05, Michael S. Tsirkin wrote: On Thu, Mar 14, 2024 at 05:49:23PM +1000, Gavin Shan wrote: The issue is reported by Yihuang Yu who have 'netperf' test on NVidia's grace-grace and grace-hopper machines. The 'netperf' client is started in the VM hosted by gr

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-14 Thread Gavin Shan
On 3/14/24 21:50, Michael S. Tsirkin wrote: On Thu, Mar 14, 2024 at 08:15:22PM +1000, Gavin Shan wrote: On 3/14/24 18:05, Michael S. Tsirkin wrote: On Thu, Mar 14, 2024 at 05:49:23PM +1000, Gavin Shan wrote: The issue is reported by Yihuang Yu who have 'netperf' test on NVidia

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-15 Thread Gavin Shan
+ Will, Catalin and Matt from Nvidia On 3/14/24 22:59, Michael S. Tsirkin wrote: On Thu, Mar 14, 2024 at 10:50:15PM +1000, Gavin Shan wrote: On 3/14/24 21:50, Michael S. Tsirkin wrote: On Thu, Mar 14, 2024 at 08:15:22PM +1000, Gavin Shan wrote: On 3/14/24 18:05, Michael S. Tsirkin wrote

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-15 Thread Gavin Shan
On 3/15/24 21:05, Michael S. Tsirkin wrote: On Fri, Mar 15, 2024 at 08:45:10PM +1000, Gavin Shan wrote: Yes, I guess smp_wmb() ('dmb') is buggy on NVidia's grace-hopper platform. I tried to reproduce it with my own driver where one thread writes to the shared buffer and anoth

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-17 Thread Gavin Shan
On 3/18/24 02:50, Michael S. Tsirkin wrote: On Fri, Mar 15, 2024 at 09:24:36PM +1000, Gavin Shan wrote: On 3/15/24 21:05, Michael S. Tsirkin wrote: On Fri, Mar 15, 2024 at 08:45:10PM +1000, Gavin Shan wrote: Yes, I guess smp_wmb() ('dmb') is buggy on NVidia's grace-hopper pla

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-18 Thread Gavin Shan
On 3/19/24 02:59, Will Deacon wrote: On Thu, Mar 14, 2024 at 05:49:23PM +1000, Gavin Shan wrote: The issue is reported by Yihuang Yu who have 'netperf' test on NVidia's grace-grace and grace-hopper machines. The 'netperf' client is started in the VM hosted by grace-

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-18 Thread Gavin Shan
On 3/19/24 16:09, Michael S. Tsirkin wrote: diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 49299b1f9ec7..7d852811c912 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -687,9 +687,15 @@ static inline int virtqueue_add_split(struct vir

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-18 Thread Gavin Shan
On 3/19/24 16:43, Michael S. Tsirkin wrote: On Tue, Mar 19, 2024 at 04:38:49PM +1000, Gavin Shan wrote: On 3/19/24 16:09, Michael S. Tsirkin wrote: diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 49299b1f9ec7..7d852811c912 100644 --- a/drivers/virtio

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-18 Thread Gavin Shan
On 3/19/24 16:10, Michael S. Tsirkin wrote: On Tue, Mar 19, 2024 at 02:09:34AM -0400, Michael S. Tsirkin wrote: On Tue, Mar 19, 2024 at 02:59:23PM +1000, Gavin Shan wrote: On 3/19/24 02:59, Will Deacon wrote: [...] diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-19 Thread Gavin Shan
On 3/19/24 17:04, Michael S. Tsirkin wrote: On Tue, Mar 19, 2024 at 04:54:15PM +1000, Gavin Shan wrote: On 3/19/24 16:10, Michael S. Tsirkin wrote: On Tue, Mar 19, 2024 at 02:09:34AM -0400, Michael S. Tsirkin wrote: On Tue, Mar 19, 2024 at 02:59:23PM +1000, Gavin Shan wrote: On 3/19/24 02:59

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-19 Thread Gavin Shan
On 3/19/24 17:09, Michael S. Tsirkin wrote: On Tue, Mar 19, 2024 at 04:49:50PM +1000, Gavin Shan wrote: On 3/19/24 16:43, Michael S. Tsirkin wrote: On Tue, Mar 19, 2024 at 04:38:49PM +1000, Gavin Shan wrote: On 3/19/24 16:09, Michael S. Tsirkin wrote: diff --git a/drivers/virtio

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-19 Thread Gavin Shan
On 3/20/24 04:22, Will Deacon wrote: On Tue, Mar 19, 2024 at 02:59:23PM +1000, Gavin Shan wrote: On 3/19/24 02:59, Will Deacon wrote: drivers/virtio/virtio_ring.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-19 Thread Gavin Shan
On 3/20/24 10:49, Michael S. Tsirkin wrote:> I think you are wasting the time with these tests. Even if it helps what does this tell us? Try setting a flag as I suggested elsewhere. Then check it in vhost. Or here's another idea - possibly easier. Copy the high bits from index into ring itself. T

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-21 Thread Gavin Shan
On 3/21/24 03:15, Keir Fraser wrote: On Wed, Mar 20, 2024 at 03:24:16PM +1000, Gavin Shan wrote: Before this patch was posted, I had debugging code to record last 16 transactions to the available and used queue from guest and host side. It did reveal the wrong head was fetched from the

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-25 Thread Gavin Shan
On 3/20/24 17:14, Michael S. Tsirkin wrote: On Wed, Mar 20, 2024 at 03:24:16PM +1000, Gavin Shan wrote: On 3/20/24 10:49, Michael S. Tsirkin wrote:> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 6f7e5010a673..79456706d0bd 100644 --- a/drivers/vir

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-26 Thread Gavin Shan
On 3/27/24 01:46, Will Deacon wrote: On Tue, Mar 26, 2024 at 11:43:13AM +, Will Deacon wrote: Ok, long shot after eyeballing the vhost code, but does the diff below help at all? It looks like vhost_vq_avail_empty() can advance the value saved in 'vq->avail_idx' but without the read barrier

[PATCH v2 0/2] vhost: Fix stale available ring entries

2024-03-26 Thread Gavin Shan
o a stale available ring entry can be fetched in vhost_get_vq_desc(). Fix it by adding smp_rmb() in those two functions. Note that I need two patches so that they can be easily picked up by the stable kernel. With the changes, I'm unable to hit the issue again. Gavin Shan (2): vhost: Add smp_rmb(

[PATCH v2 1/2] vhost: Add smp_rmb() in vhost_vq_avail_empty()

2024-03-26 Thread Gavin Shan
: 275bf960ac697 ("vhost: better detection of available buffers") Cc: # v4.11+ Reported-by: Yihuang Yu Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 045f66

[PATCH v2 2/2] vhost: Add smp_rmb() in vhost_enable_notify()

2024-03-26 Thread Gavin Shan
s: d3bb267bbdcb ("vhost: cache avail index in vhost_enable_notify()") Cc: # v5.18+ Reported-by: Yihuang Yu Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c

Re: [PATCH v2 0/2] vhost: Fix stale available ring entries

2024-03-26 Thread Gavin Shan
On 3/27/24 09:38, Gavin Shan wrote: The issue was reported by Yihuang Yu on NVidia's grace-hopper (ARM64) platform. The wrong head (available ring entry) is seen by the guest when running 'netperf' on the guest and running 'netserver' on another NVidia's grace-

Re: [PATCH] virtio_ring: Fix the stale index in available ring

2024-03-26 Thread Gavin Shan
On 3/27/24 09:14, Gavin Shan wrote: On 3/27/24 01:46, Will Deacon wrote: On Tue, Mar 26, 2024 at 11:43:13AM +, Will Deacon wrote: Ok, long shot after eyeballing the vhost code, but does the diff below help at all? It looks like vhost_vq_avail_empty() can advance the value saved in &#x

Re: [PATCH v2 1/2] vhost: Add smp_rmb() in vhost_vq_avail_empty()

2024-03-26 Thread Gavin Shan
On 3/27/24 12:44, Jason Wang wrote: On Wed, Mar 27, 2024 at 10:34 AM Jason Wang wrote: On Wed, Mar 27, 2024 at 7:39 AM Gavin Shan wrote: A smp_rmb() has been missed in vhost_vq_avail_empty(), spotted by Will Deacon . Otherwise, it's not ensured the available ring entries pushed by gues

Re: [PATCH v2 2/2] vhost: Add smp_rmb() in vhost_enable_notify()

2024-03-26 Thread Gavin Shan
On 3/27/24 12:41, Jason Wang wrote: On Wed, Mar 27, 2024 at 7:39 AM Gavin Shan wrote: A smp_rmb() has been missed in vhost_enable_notify(), inspired by Will Deacon . Otherwise, it's not ensured the available ring entries pushed by guest can be observed by vhost in time, leading to

Re: [PATCH v2 1/2] vhost: Add smp_rmb() in vhost_vq_avail_empty()

2024-03-27 Thread Gavin Shan
On 3/27/24 14:08, Gavin Shan wrote: On 3/27/24 12:44, Jason Wang wrote: On Wed, Mar 27, 2024 at 10:34 AM Jason Wang wrote: On Wed, Mar 27, 2024 at 7:39 AM Gavin Shan wrote: A smp_rmb() has been missed in vhost_vq_avail_empty(), spotted by Will Deacon . Otherwise, it's not ensure

[PATCH v3 0/3] vhost: Fix stale available ring entries

2024-03-27 Thread Gavin Shan
@redhat.com Changelog = v3: Improved change log (Jason) Improved comments and added PATCH[v3 3/3] to execute smp_rmb() in vhost_get_avail_idx() (Michael) Gavin Shan (3): vhost: Add smp_rmb() in vhost_vq_avail_empty() vhost: Add smp_rmb() in vhost_enable_no

[PATCH v3 1/3] vhost: Add smp_rmb() in vhost_vq_avail_empty()

2024-03-27 Thread Gavin Shan
sc(). Note that it should be safe until vq->avail_idx is changed by commit 275bf960ac697 ("vhost: better detection of available buffers"). Fixes: 275bf960ac69 ("vhost: better detection of available buffers") Cc: # v4.11+ Reported-by: Yihuang Yu Suggested-by: Will Deaco

[PATCH v3 2/3] vhost: Add smp_rmb() in vhost_enable_notify()

2024-03-27 Thread Gavin Shan
at it should be safe until vq->avail_idx is changed by commit d3bb267bbdcb ("vhost: cache avail index in vhost_enable_notify()"). Fixes: d3bb267bbdcb ("vhost: cache avail index in vhost_enable_notify()") Cc: # v5.18+ Reported-by: Yihuang Yu Suggested-by: Will Deacon Sign

[PATCH v3 3/3] vhost: Improve vhost_get_avail_idx() with smp_rmb()

2024-03-27 Thread Gavin Shan
;t to worry about the memory barrier. Suggested-by: Michael S. Tsirkin Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 75 +++ 1 file changed, 26 insertions(+), 49 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 32686c7

Re: [PATCH v2 1/2] vhost: Add smp_rmb() in vhost_vq_avail_empty()

2024-03-27 Thread Gavin Shan
On 3/27/24 22:07, Michael S. Tsirkin wrote: On Wed, Mar 27, 2024 at 09:38:45AM +1000, Gavin Shan wrote: A smp_rmb() has been missed in vhost_vq_avail_empty(), spotted by Will Deacon . Otherwise, it's not ensured the available ring entries pushed by guest can be observed by vhost in

Re: [PATCH v2 1/2] vhost: Add smp_rmb() in vhost_vq_avail_empty()

2024-03-27 Thread Gavin Shan
On 3/27/24 17:42, Jason Wang wrote: On Wed, Mar 27, 2024 at 3:35 PM Gavin Shan wrote: On 3/27/24 14:08, Gavin Shan wrote: On 3/27/24 12:44, Jason Wang wrote: On Wed, Mar 27, 2024 at 10:34 AM Jason Wang wrote: On Wed, Mar 27, 2024 at 7:39 AM Gavin Shan wrote: A smp_rmb() has been missed

Re: [PATCH v3 3/3] vhost: Improve vhost_get_avail_idx() with smp_rmb()

2024-03-30 Thread Gavin Shan
On 3/28/24 19:31, Michael S. Tsirkin wrote: On Thu, Mar 28, 2024 at 10:21:49AM +1000, Gavin Shan wrote: All the callers of vhost_get_avail_idx() are concerned to the memory barrier, imposed by smp_rmb() to ensure the order of the available ring entry read and avail_idx read. Improve

Re: [PATCH v3 3/3] vhost: Improve vhost_get_avail_idx() with smp_rmb()

2024-04-07 Thread Gavin Shan
Hi Michael, On 3/30/24 19:02, Gavin Shan wrote: On 3/28/24 19:31, Michael S. Tsirkin wrote: On Thu, Mar 28, 2024 at 10:21:49AM +1000, Gavin Shan wrote: All the callers of vhost_get_avail_idx() are concerned to the memory barrier, imposed by smp_rmb() to ensure the order of the available ring

[PATCH 0/4] vhost: Cleanup

2024-04-22 Thread Gavin Shan
eformat vhost_{get, put}_user() by using tab instead of space as the terminator for each line Gavin Shan (4): vhost: Drop variable last_avail_idx in vhost_get_vq_desc() vhost: Improve vhost_get_avail_idx() with smp_rmb() vhost: Improve vhost_get_avail_head() vhost: Reforma

[PATCH 1/4] vhost: Drop variable last_avail_idx in vhost_get_vq_desc()

2024-04-22 Thread Gavin Shan
The local variable @last_avail_idx is equivalent to vq->last_avail_idx. So the code can be simplified a bit by dropping the local variable @last_avail_idx. No functional change intended. Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 15 ++- 1 file changed, 6 inserti

[PATCH 2/4] vhost: Improve vhost_get_avail_idx() with smp_rmb()

2024-04-22 Thread Gavin Shan
;t to worry about the memory barrier. No functional change intended. Suggested-by: Michael S. Tsirkin Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 91 --- 1 file changed, 34 insertions(+), 57 deletions(-) diff --git a/drivers/vhost/vhost.c b/dr

[PATCH 3/4] vhost: Improve vhost_get_avail_head()

2024-04-22 Thread Gavin Shan
Improve vhost_get_avail_head() so that the head or errno is returned. With it, the relevant sanity checks are squeezed to vhost_get_avail_head() and vhost_get_vq_desc() is further simplified. No functional change intended. Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 43

[PATCH 4/4] vhost: Reformat vhost_{get, put}_user()

2024-04-22 Thread Gavin Shan
Reformat the macros to use tab as the terminator for each line so that it looks clean. No functional change intended. Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 60 +-- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers

Re: [PATCH v3 3/3] vhost: Improve vhost_get_avail_idx() with smp_rmb()

2024-04-22 Thread Gavin Shan
On 4/23/24 06:46, Michael S. Tsirkin wrote: On Mon, Apr 08, 2024 at 02:15:24PM +1000, Gavin Shan wrote: On 3/30/24 19:02, Gavin Shan wrote: On 3/28/24 19:31, Michael S. Tsirkin wrote: On Thu, Mar 28, 2024 at 10:21:49AM +1000, Gavin Shan wrote: All the callers of vhost_get_avail_idx() are

Re: [PATCH 3/4] vhost: Improve vhost_get_avail_head()

2024-04-25 Thread Gavin Shan
And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Gavin-Shan/vhost-Drop-variable-last_avail_idx-in-vhost_get_vq_desc/20240423-112803 base: https://g

[PATCH v2 0/4] vhost: Cleanup

2024-04-29 Thread Gavin Shan
eformat vhost_{get, put}_user() by using tab instead of space as the terminator for each line Gavin Shan (3): vhost: Drop variable last_avail_idx in vhost_get_vq_desc() vhost: Improve vhost_get_avail_head() vhost: Reformat vhost_{get, put}_user() Michael S. Tsirkin (1): vhost: Impr

[PATCH v2 1/4] vhost: Improve vhost_get_avail_idx() with smp_rmb()

2024-04-29 Thread Gavin Shan
nced. With it, the callers needn't to worry about the memory barrier. No functional change intended. Signed-off-by: Michael S. Tsirkin [gshan: repainted vhost_get_avail_idx()] Reviewed-by: Gavin Shan Acked-by: Will Deacon --- drivers/vhost/vhost.c | 106 +--

[PATCH v2 3/4] vhost: Improve vhost_get_avail_head()

2024-04-29 Thread Gavin Shan
Improve vhost_get_avail_head() so that the head or errno is returned. With it, the relevant sanity checks are squeezed to vhost_get_avail_head() and vhost_get_vq_desc() is further simplified. No functional change intended. Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 50

[PATCH v2 2/4] vhost: Drop variable last_avail_idx in vhost_get_vq_desc()

2024-04-29 Thread Gavin Shan
The local variable @last_avail_idx is equivalent to vq->last_avail_idx. So the code can be simplified a bit by dropping the local variable @last_avail_idx. No functional change intended. Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 7 +++ 1 file changed, 3 insertions(+)

[PATCH v2 4/4] vhost: Reformat vhost_{get, put}_user()

2024-04-29 Thread Gavin Shan
Reformat the macros to use tab as the terminator for each line so that it looks clean. No functional change intended. Signed-off-by: Gavin Shan --- drivers/vhost/vhost.c | 60 +-- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers

Re: [PATCH 0/4] vhost: Cleanup

2024-04-29 Thread Gavin Shan
On 4/29/24 17:02, Michael S. Tsirkin wrote: On Tue, Apr 23, 2024 at 01:24:03PM +1000, Gavin Shan wrote: This is suggested by Michael S. Tsirkin according to [1] and the goal is to apply smp_rmb() inside vhost_get_avail_idx() if needed. With it, the caller of the function needn't to worry

Re: [PATCH v2 2/4] vhost: Drop variable last_avail_idx in vhost_get_vq_desc()

2024-04-29 Thread Gavin Shan
On 4/30/24 04:45, Michael S. Tsirkin wrote: On Mon, Apr 29, 2024 at 08:13:58PM +1000, Gavin Shan wrote: The local variable @last_avail_idx is equivalent to vq->last_avail_idx. So the code can be simplified a bit by dropping the local variable @last_avail_idx. No functional change inten

Re: [PATCH v2 1/4] vhost: Improve vhost_get_avail_idx() with smp_rmb()

2024-04-29 Thread Gavin Shan
On 4/30/24 04:44, Michael S. Tsirkin wrote: On Mon, Apr 29, 2024 at 08:13:57PM +1000, Gavin Shan wrote: From: "Michael S. Tsirkin" All the callers of vhost_get_avail_idx() are concerned to the memory *with* the memory barrier Thanks, will be corrected in v3. barrier, imposed

[PATCH v3] vhost: Improve vhost_get_avail_idx() with smp_rmb()

2024-04-29 Thread Gavin Shan
ty ring in some places, but as non-empty ring in other places. This patch doesn't attempt to change the existing behaviour. No functional change intended. Signed-off-by: Michael S. Tsirkin Reviewed-by: Gavin Shan Acked-by: Will Deacon --- v3: Improved commit log and comments as Michael su

Re: [PATCH v2 0/4] vhost: Cleanup

2024-04-29 Thread Gavin Shan
On 4/30/24 04:50, Michael S. Tsirkin wrote: On Mon, Apr 29, 2024 at 08:13:56PM +1000, Gavin Shan wrote: This is suggested by Michael S. Tsirkin according to [1] and the goal is to apply smp_rmb() inside vhost_get_avail_idx() if needed. With it, the caller of the function needn't to worry

Re: [PATCH] PCI: Clear bridge MEM_64 flag if one child does not support it

2014-12-08 Thread Gavin Shan
On Mon, Dec 08, 2014 at 03:59:54PM -0800, Yinghai Lu wrote: >On Mon, Dec 8, 2014 at 2:56 PM, Benjamin Herrenschmidt > wrote: >> On Mon, 2014-12-08 at 13:52 -0800, Yinghai Lu wrote: >>> 2. or scan the children resource other than ROM to clear bridge MEM_64 >>>for mmio pref. >>> >>> The patch is

Re: [PATCH] PCI: Clear bridge MEM_64 flag if one child does not support it

2014-12-08 Thread Gavin Shan
On Mon, Dec 08, 2014 at 03:59:54PM -0800, Yinghai Lu wrote: >On Mon, Dec 8, 2014 at 2:56 PM, Benjamin Herrenschmidt > wrote: >> On Mon, 2014-12-08 at 13:52 -0800, Yinghai Lu wrote: >>> 2. or scan the children resource other than ROM to clear bridge MEM_64 >>>for mmio pref. >>> >>> The patch is

Re: [PATCH] PCI: Clear all bridge res MEM_64 if host bridge has non mem64

2014-12-10 Thread Gavin Shan
On Tue, Dec 09, 2014 at 01:34:31PM -0800, Yinghai Lu wrote: >So we could use bridge 64bit mem pref for children mem pref instead of >forcing them into bridge mem. > >Could help Marek's system as his system is using _CRS, and all mem res is under >4G. > >Link: https://bugzilla.kernel.org/show_bug.cg

Re: [PATCH kernel] powerpc/powernv/ioda2: Add devices only from buses which belong to PE

2015-06-11 Thread Gavin Shan
uld be added to lower level PE rather to the root PE. > >This limits pnv_ioda_setup_bus_dma() invocation to only PEs which own >all subordinate buses. > >Suggested-by: Gavin Shan >Signed-off-by: Alexey Kardashevskiy Alexey, I think it's good candidate for stable. Thanks, G

Re: [PATCH kernel] powerpc/powernv/ioda2: Add devices only from buses which belong to PE

2015-06-14 Thread Gavin Shan
On Fri, Jun 12, 2015 at 08:06:43AM -0700, Nishanth Aravamudan wrote: >On 12.06.2015 [16:47:03 +1000], Gavin Shan wrote: >> On Fri, Jun 12, 2015 at 04:19:17PM +1000, Alexey Kardashevskiy wrote: >> >The existing code puts all devices from a root PE to the same IOMMU group. &

Re: [PATCH kernel v11 33/34] vfio: powerpc/spapr: Register memory and define IOMMU v2

2015-06-04 Thread Gavin Shan
On Fri, May 29, 2015 at 06:44:57PM +1000, Alexey Kardashevskiy wrote: >The existing implementation accounts the whole DMA window in >the locked_vm counter. This is going to be worse with multiple >containers and huge DMA windows. Also, real-time accounting would requite >additional tracking of acco

Re: [PATCH kernel v11 05/34] powerpc/iommu: Always release iommu_table in iommu_free_table()

2015-06-04 Thread Gavin Shan
DMA windows, we will need to be able to release >iommu_table even if it was used for VFIO in which case it_map is NULL >so does the patch. > >Signed-off-by: Alexey Kardashevskiy Reviewed-by: Gavin Shan Thanks, Gavin >--- >Changes: >v11: >* fixed parameter checks

Re: [PATCH kernel v11 16/34] powerpc/spapr: vfio: Replace iommu_table with iommu_table_group

2015-06-04 Thread Gavin Shan
_pci_ioda2_setup_dma_pe as this is where DMA is actually initialized. >This change is here because those lines had to be changed anyway. > >This should cause no behavioural change. > >Signed-off-by: Alexey Kardashevskiy >[aw: for the vfio related changes] >Acked-by: Alex Williamson

Re: [PATCH kernel v11 20/34] powerpc/powernv/ioda2: Move TCE kill register address to PE

2015-06-04 Thread Gavin Shan
and 64bit DMA was handled via >bypass window (which has no table so no cache was used) but this is going >to change with Dynamic DMA windows (DDW). > >Signed-off-by: Alexey Kardashevskiy Reviewed-by: Gavin Shan Thanks, Gavin >--- >Changes: >v11: >* s/pnv_pci_ioda2_tvt_inv

Re: [PATCH kernel v11 21/34] powerpc/powernv/ioda2: Add TCE invalidation for all attached groups

2015-06-04 Thread Gavin Shan
PE needs to be invalidated so does the patch. > >This does not change pnv_pci_ioda1_tce_invalidate() as there is no plan >to enable TCE table sharing on PHBs older than IODA2. > >Signed-off-by: Alexey Kardashevskiy Reviewed-by: Gavin Shan >--- >Changes: >v10: >

[PATCH v2 08/21] KVM: arm64: Support SDEI_EVENT_STATUS hypercall

2021-02-08 Thread Gavin Shan
This supports SDEI_EVENT_STATUS hypercall. It's used by the guest to retrieve a bitmap to indicate the SDEI event states, including registration, enablement and delivery state. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 50 +++ 1 file ch

[PATCH v2 09/21] KVM: arm64: Support SDEI_EVENT_GET_INFO hypercall

2021-02-08 Thread Gavin Shan
This supports SDEI_EVENT_GET_INFO hypercall. It's used by the guest to retrieve various information about the supported (exported) events, including type, signaled, route mode and affinity for the shared events. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c

[PATCH v2 01/21] KVM: arm64: Introduce template for inline functions

2021-02-08 Thread Gavin Shan
by SDEI virtualization support. Signed-off-by: Gavin Shan --- include/kvm/arm_hypercalls.h | 34 +++--- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/include/kvm/arm_hypercalls.h b/include/kvm/arm_hypercalls.h index 0e2509d27910..1120eff7aa28 100644

[PATCH v2 16/21] KVM: arm64: Support SDEI ioctl commands on VM

2021-02-08 Thread Gavin Shan
ulate the registered SDEI event Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/include/uapi/asm/kvm_sdei.h | 17 +++ arch/arm64/kvm/arm.c | 3 + arch/arm64/kvm/sdei.c | 171 + include/uapi/linux/

[PATCH v2 21/21] KVM: selftests: Add SDEI test case

2021-02-08 Thread Gavin Shan
ster event) SDEI_1_0_FN_SDEI_PE_MASK(CPU offline) Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/aarch64/sdei.c | 172 + 2 files changed, 173 insertions(+) create mode 100644 tools/testing/selftests/kvm/aarch64/sdei.c di

[PATCH v2 13/21] KVM: arm64: Impment SDEI event delivery

2021-02-08 Thread Gavin Shan
. * SDEI event with critical priority can preempt those with normal priority. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/kvm/arm.c | 3 ++ arch/arm64/kvm/sdei.c | 84

[PATCH v2 18/21] KVM: arm64: Support SDEI event injection

2021-02-08 Thread Gavin Shan
This supports SDEI event injection by implementing kvm_sdei_inject(). It's called by kernel directly or VMM through ioctl command to inject SDEI event to the specific vCPU. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 2 + arch/arm64/include/uapi/asm/kvm_sdei.h

[PATCH v2 19/21] KVM: arm64: Support SDEI event cancellation

2021-02-08 Thread Gavin Shan
ynchronous page fault. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/kvm/sdei.c | 49 +++ 2 files changed, 50 insertions(+) diff --git a/arch/arm64/include/asm/kvm_sdei.h b/arch/arm64/include/asm/kvm_sdei.h ind

[PATCH v2 20/21] KVM: arm64: Export SDEI capability

2021-02-08 Thread Gavin Shan
The SDEI functionality is ready to be exported so far. This adds new capability (KVM_CAP_ARM_SDEI) and exports it. Signed-off-by: Gavin Shan --- arch/arm64/kvm/arm.c | 3 +++ include/uapi/linux/kvm.h | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm

[PATCH v2 12/21] KVM: arm64: Support SDEI_{PRIVATE, SHARED}_RESET hypercall

2021-02-08 Thread Gavin Shan
This supports SDEI_{PRIVATE, SHARED}_RESET. They are used by the guest to purge the private or shared SDEI events, which are registered previously. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 29 + 1 file changed, 29 insertions(+) diff --git a/arch/arm64

[PATCH v2 11/21] KVM: arm64: Support SDEI_PE_{MASK, UNMASK} hypercall

2021-02-08 Thread Gavin Shan
This supports SDEI_PE_{MASK, UNMASK} hypercall. They are used by the guest to stop the specific vCPU from receiving SDEI events. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b

[PATCH v2 00/21] Support SDEI Virtualization

2021-02-08 Thread Gavin Shan
in) * Implementation is almost rewritten as the data structures are totally changed (Gavin) * Added ioctl commands to support migration(Gavin) Gavin Shan (21): KVM: arm64: Introduce template for inline functions KVM: arm64: A

[PATCH v2 04/21] KVM: arm64: Support SDEI_EVENT_REGISTER hypercall

2021-02-08 Thread Gavin Shan
registered successfully, the KVM SDEI event (object) is created or updated because the same KVM SDEI event is shared by multiple vCPUs if it's a private event. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 122 ++ 1 file changed, 122 insertions

[PATCH v2 02/21] KVM: arm64: Add SDEI virtualization infrastructure

2021-02-08 Thread Gavin Shan
ect to save the preempted context during SDEI event delivery. The error is returned for all SDEI hypercalls for now. They will be supported by subsequent patches. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 4 + arch/arm64/include/asm/kvm_sdei.h | 118 ++

[PATCH v2 10/21] KVM: arm64: Support SDEI_EVENT_ROUTING_SET hypercall

2021-02-08 Thread Gavin Shan
This supports SDEI_EVENT_ROUTING_SET hypercall. It's used by the guest to set route mode and affinity for the registered KVM event. It's only valid for the shared events. It's not allowed to do so when the corresponding event has been raised to the guest. Signed-off-by: Gavin

[PATCH v2 06/21] KVM: arm64: Support SDEI_EVENT_CONTEXT hypercall

2021-02-08 Thread Gavin Shan
This supports SDEI_EVENT_CONTEXT hypercall. It's used by the guest to retrieved the original registers (R0 - R17) in its SDEI event handler. Those registers can be corrupted during the SDEI event delivery. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c

[PATCH v2 17/21] KVM: arm64: Support SDEI ioctl commands on vCPU

2021-02-08 Thread Gavin Shan
state related to SDEI handling * KVM_SDEI_CMD_SET_VCPU_STATE Populate vCPU state related to SDEI handling Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/include/uapi/asm/kvm_sdei.h | 7 + arch/arm64/kvm/arm.c | 3 + arch/arm6

[PATCH v2 14/21] KVM: arm64: Support SDEI_EVENT_{COMPLETE, COMPLETE_AND_RESUME} hypercall

2021-02-08 Thread Gavin Shan
the interrupted context. * If it's SDEI_EVENT_COMPLETE_AND_RESUME hypercall, IRQ exception is injected. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_emulate.h | 1 + arch/arm64/include/asm/kvm_host.h| 1 + arch/arm64/kvm/hyp/exception.c | 7 +++ arch/arm6

[PATCH v2 07/21] KVM: arm64: Support SDEI_EVENT_UNREGISTER hypercall

2021-02-08 Thread Gavin Shan
cific vCPU once it's unregistered successfully. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 61 +++ 1 file changed, 61 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index b4162efda470..a3ba69dc91cb 100644 --- a/arch/arm64/kv

[PATCH v2 03/21] KVM: arm64: Support SDEI_VERSION hypercall

2021-02-08 Thread Gavin Shan
This supports SDEI_VERSION hypercall by returning v1.0.0 simply when the functionality is supported on the VM and vCPU. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index

[PATCH v2 05/21] KVM: arm64: Support SDEI_EVENT_{ENABLE, DISABLE} hypercall

2021-02-08 Thread Gavin Shan
ic vCPU. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 68 +++ 1 file changed, 68 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index d3ea3eee154b..b022ce0a202b 100644 --- a/arch/arm64/kvm/sdei.c +++ b/arch/arm64/kvm/sdei

[PATCH v2 15/21] KVM: arm64: Support SDEI event notifier

2021-02-08 Thread Gavin Shan
The owner of the SDEI event, like asynchronous page fault, need know the state of injected SDEI event. This supports SDEI event state updating by introducing notifier mechanism. It's notable the notifier (handler) should be capable of migration. Signed-off-by: Gavin Shan --- arch/arm64/in

[PATCH v2 00/17] Support Asynchronous Page Fault

2021-02-08 Thread Gavin Shan
_control" dymaicall and use it to check if the feature has been enabled. The kernel option (CONFIG_KVM_ASYNC_PF) isn't used. (James) * Add document to explain the design (James) * Make GFN hash table management generic

[PATCH v2 03/17] KVM: async_pf: Make GFN slot management generic

2021-02-08 Thread Gavin Shan
rm and arm64 in subsequent patches. Signed-off-by: Gavin Shan --- include/linux/kvm_host.h | 18 + virt/kvm/Kconfig | 3 ++ virt/kvm/async_pf.c | 79 3 files changed, 100 insertions(+) diff --git a/include/linux/kvm_host.h b/include/l

[PATCH v2 02/17] KVM: async_pf: Add helper function to check completion queue

2021-02-08 Thread Gavin Shan
e all replaced by the newly introduced helper as list_empty() and list_empty_careful() are interchangeable. The stub kvm_check_async_pf_completion() on !CONFIG_KVM_ASYNC_PF is also introduced. It will be used by subsequent patch. Signed-off-by: Gavin Shan --- arch/x86/kvm/x86.c | 2 +- in

[PATCH v2 01/17] KVM: async_pf: Move struct kvm_async_pf around

2021-02-08 Thread Gavin Shan
unction for next patch. This shouldn't cause logical changes. Signed-off-by: Gavin Shan --- include/linux/kvm_host.h | 43 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index f3b1013

[PATCH v2 04/17] KVM: x86: Use generic async PF slot management

2021-02-08 Thread Gavin Shan
ff-by: Gavin Shan --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/Kconfig| 1 + arch/x86/kvm/mmu/mmu.c | 2 +- arch/x86/kvm/x86.c | 86 +++-- 4 files changed, 8 insertions(+), 82 deletions(-) diff --git a/arch/x86/includ

[PATCH v2 05/17] arm64: Probe for the presence of KVM hypervisor services during boot

2021-02-08 Thread Gavin Shan
tible with KVM. Once this has been established, additional services can be discovered via a feature bitmap. Signed-off-by: Will Deacon Signed-off-by: Gavin Shan --- arch/arm64/include/asm/hypervisor.h | 11 ++ arch/arm64/kernel/setup.c | 32 + include

[PATCH v2 06/17] KVM: arm64: Advertise KVM UID to guests via SMCCC

2021-02-08 Thread Gavin Shan
From: Will Deacon We can advertise ourselves to guests as KVM and provide a basic features bitmap for discoverability of future hypervisor services. Signed-off-by: Will Deacon Signed-off-by: Gavin Shan --- arch/arm64/kvm/hypercalls.c | 27 ++- 1 file changed, 18

[PATCH v2 07/17] KVM: arm64: Export kvm_handle_user_mem_abort()

2021-02-08 Thread Gavin Shan
near future. They are moved to mmu.c and renamed accordingly. kvm_vcpu_trap_is_exec_fault() is_exec_fault() kvm_is_write_fault() is_write_fault() kvm_vcpu_trap_get_fault_level() Replaced by esr_dabt_get_fault_level() Signed-off-by: Gavin Shan --- arch/arm64/in

[PATCH v2 08/17] KVM: arm64: Add paravirtualization header files

2021-02-08 Thread Gavin Shan
onous page fault in subsequent patches: include/uapi/asm-generic/kvm_para.h include/asm-generic/kvm_para.h arch/arm64/include/uapi/asm/kvm_para.h arch/arm64/include/asm/kvm_para.h Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_para.h | 27 ++

[PATCH v2 09/17] KVM: arm64: Support page-not-present notification

2021-02-08 Thread Gavin Shan
uested page. "struct kvm{_,_arch}async_pf" is associated with the worker, to track the work. The feature isn't enabled by CONFIG_KVM_ASYNC_PF yet. Also, the page-ready notification delivery and control path isn't implemented and will be done in the subsequent patches. Si

[PATCH v2 10/17] KVM: arm64: Support page-ready notification

2021-02-08 Thread Gavin Shan
ready notification. The region is represented by "struct kvm_vcpu_pv_apf_data". The feature isn't enabled by CONFIG_KVM_ASYNC_PF yet. Also, the control path isn't implemented and will be done in the subsequent patches. Signed-off-by: Gavin Shan --- arch/arm64/include/

[PATCH v2 12/17] KVM: arm64: Support async PF ioctl commands

2021-02-08 Thread Gavin Shan
KVM_ARM_ASYNC_PF_CMD_SET_CONTROL Set control block when VM is migrated Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 14 +++ arch/arm64/include/uapi/asm/kvm.h | 19 + arch/arm64/kvm/arm.c | 6 +++ arch/arm64/kvm/async_pf.c | 64

[PATCH v2 11/17] KVM: arm64: Support async PF hypercalls

2021-02-08 Thread Gavin Shan
quent patches. Signed-off-by: Gavin Shan --- arch/arm64/kvm/async_pf.c | 119 ++ include/linux/arm-smccc.h | 5 ++ 2 files changed, 124 insertions(+) diff --git a/arch/arm64/kvm/async_pf.c b/arch/arm64/kvm/async_pf.c index f73c406456e9..4734c5b26aa8 100644 --- a

[PATCH v2 13/17] KVM: arm64: Export async PF capability

2021-02-08 Thread Gavin Shan
This exports the asynchronous page fault capability: * Identify capability KVM_CAP_ASYNC_{PF, PF_INT}. * Standardize SDEI event for asynchronous page fault. * Enable kernel config CONFIG_KVM_ASYNC_{PF, PF_SLOT}. Signed-off-by: Gavin Shan --- arch/arm64/include/uapi/asm/kvm_sdei.h

[PATCH v2 14/17] arm64: Detect async PF para-virtualization feature

2021-02-08 Thread Gavin Shan
page fault. This also adds kernel option (CONFIG_KVM_GUEST), which is the umbrella for the optimizations related to KVM para-virtualization. Signed-off-by: Gavin Shan --- arch/arm64/Kconfig | 11 +++ arch/arm64/include/asm/kvm_para.h | 12 +++- arch/arm64

[PATCH v2 17/17] KVM: arm64: Add async PF document

2021-02-08 Thread Gavin Shan
This adds document to explain the interface for asynchronous page fault and how it works in general. Signed-off-by: Gavin Shan --- Documentation/virt/kvm/arm/apf.rst | 143 +++ Documentation/virt/kvm/arm/index.rst | 1 + 2 files changed, 144 insertions(+) create

  1   2   3   >