All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y
@ 2022-12-23  0:09 Tyler Hicks
  2022-12-23  0:09 ` [PATCH 5.15 1/2] tools/include: Add _RET_IP_ and math definitions to kernel.h Tyler Hicks
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tyler Hicks @ 2022-12-23  0:09 UTC (permalink / raw)
  To: gregkh, stable
  Cc: Tyler Hicks, Paolo Bonzini, Shuah Khan, kvm, linux-kselftest,
	linux-kernel, Gavin Shan, Marc Zyngier, Karolina Drobnik,
	Mike Rapoport

From: "Tyler Hicks" <code@tyhicks.com>

The backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of
pages for memory slot in memslot_modification_stress_test") broke the
build of the KVM selftest memslot_modification_stress_test.c source file
in two ways:

- Incorrectly assumed that max_t() was defined despite commit
  5cf67a6051ea ("tools/include: Add _RET_IP_ and math definitions to
  kernel.h") not being present
- Incorrectly assumed that kvm_vm struct members could be directly
  accessed despite b530eba14c70 ("KVM: selftests: Get rid of
  kvm_util_internal.h") not being present

Backport the first commit, as it is simple enough. Work around the lack
of the second commit by using the accessors to get to the kvm_vm struct
members.

Note that the linux-6.0.y backport of commit 05c2224d4b04 ("KVM:
selftests: Fix number of pages for memory slot in
memslot_modification_stress_test") is fine because the two prerequisite
commits, mentioned above, are both present in v6.0.

Tyler

Karolina Drobnik (1):
  tools/include: Add _RET_IP_ and math definitions to kernel.h

Tyler Hicks (Microsoft) (1):
  KVM: selftests: Fix build regression by using accessor function

 tools/include/linux/kernel.h                                | 6 ++++++
 .../selftests/kvm/memslot_modification_stress_test.c        | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.34.1


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

* [PATCH 5.15 1/2] tools/include: Add _RET_IP_ and math definitions to kernel.h
  2022-12-23  0:09 [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Tyler Hicks
@ 2022-12-23  0:09 ` Tyler Hicks
  2022-12-23  0:09 ` [PATCH 5.15 2/2] KVM: selftests: Fix build regression by using accessor function Tyler Hicks
  2022-12-23 16:45 ` [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Tyler Hicks @ 2022-12-23  0:09 UTC (permalink / raw)
  To: gregkh, stable
  Cc: Karolina Drobnik, Paolo Bonzini, Shuah Khan, kvm,
	linux-kselftest, linux-kernel, Gavin Shan, Marc Zyngier,
	Mike Rapoport, Tyler Hicks

From: Karolina Drobnik <karolinadrobnik@gmail.com>

commit 5cf67a6051ea2558fd7c3d39c5a808db73073e9d upstream.

Add max_t, min_t and clamp functions, together with _RET_IP_
definition, so they can be used in testing.

Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com>
Signed-off-by: Mike Rapoport <rppt@kernel.org>
Link: https://lore.kernel.org/r/230fea382cb1e1659cdd52a55201854d38a0a149.1643796665.git.karolinadrobnik@gmail.com
[tyhicks: Backport around contextual differences due to the lack of v5.16 commit
 d6e6a27d960f ("tools: Fix math.h breakage"). That commit fixed a commit
 that was merged in v5.16-rc1 and, therefore, doesn't need to go back to
 the stable branches.]
Signed-off-by: Tyler Hicks (Microsoft) <code@tyhicks.com>
---
 tools/include/linux/kernel.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h
index a7e54a08fb54..c2e109860fbc 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.h
@@ -14,6 +14,8 @@
 #define UINT_MAX	(~0U)
 #endif
 
+#define _RET_IP_		((unsigned long)__builtin_return_address(0))
+
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 
 #define PERF_ALIGN(x, a)	__PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
@@ -52,6 +54,10 @@
 	_min1 < _min2 ? _min1 : _min2; })
 #endif
 
+#define max_t(type, x, y)	max((type)x, (type)y)
+#define min_t(type, x, y)	min((type)x, (type)y)
+#define clamp(val, lo, hi)	min((typeof(val))max(val, lo), hi)
+
 #ifndef roundup
 #define roundup(x, y) (                                \
 {                                                      \
-- 
2.34.1


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

* [PATCH 5.15 2/2] KVM: selftests: Fix build regression by using accessor function
  2022-12-23  0:09 [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Tyler Hicks
  2022-12-23  0:09 ` [PATCH 5.15 1/2] tools/include: Add _RET_IP_ and math definitions to kernel.h Tyler Hicks
@ 2022-12-23  0:09 ` Tyler Hicks
  2022-12-23 16:45 ` [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Tyler Hicks @ 2022-12-23  0:09 UTC (permalink / raw)
  To: gregkh, stable
  Cc: Tyler Hicks, Paolo Bonzini, Shuah Khan, kvm, linux-kselftest,
	linux-kernel, Gavin Shan, Marc Zyngier, Karolina Drobnik,
	Mike Rapoport

From: "Tyler Hicks" <code@tyhicks.com>

Fix the stable backport of commit 05c2224d4b04 ("KVM: selftests: Fix
number of pages for memory slot in memslot_modification_stress_test"),
which caused memslot_modification_stress_test.c build failures due to
trying to access private members of struct kvm_vm.

v6.0 commit b530eba14c70 ("KVM: selftests: Get rid of
kvm_util_internal.h") and some other commits got rid of the accessors
and made all of the KVM data structures public. Keep using the accessors
in older kernels.

There is no corresponding upstream commit for this change.

Signed-off-by: Tyler Hicks (Microsoft) <code@tyhicks.com>
---
 tools/testing/selftests/kvm/memslot_modification_stress_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c
index 1d806b8ffee2..766c1790df66 100644
--- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c
+++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c
@@ -72,7 +72,7 @@ struct memslot_antagonist_args {
 static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay,
 			       uint64_t nr_modifications)
 {
-	uint64_t pages = max_t(int, vm->page_size, getpagesize()) / vm->page_size;
+	uint64_t pages = max_t(int, vm_get_page_size(vm), getpagesize()) / vm_get_page_size(vm);
 	uint64_t gpa;
 	int i;
 
-- 
2.34.1


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

* Re: [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y
  2022-12-23  0:09 [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Tyler Hicks
  2022-12-23  0:09 ` [PATCH 5.15 1/2] tools/include: Add _RET_IP_ and math definitions to kernel.h Tyler Hicks
  2022-12-23  0:09 ` [PATCH 5.15 2/2] KVM: selftests: Fix build regression by using accessor function Tyler Hicks
@ 2022-12-23 16:45 ` Paolo Bonzini
  2022-12-25  3:33   ` Sasha Levin
  2 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2022-12-23 16:45 UTC (permalink / raw)
  To: Tyler Hicks, gregkh, stable
  Cc: Shuah Khan, kvm, linux-kselftest, linux-kernel, Gavin Shan,
	Marc Zyngier, Karolina Drobnik, Mike Rapoport

On 12/23/22 01:09, Tyler Hicks wrote:
> From: "Tyler Hicks" <code@tyhicks.com>
> 
> The backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of
> pages for memory slot in memslot_modification_stress_test") broke the
> build of the KVM selftest memslot_modification_stress_test.c source file
> in two ways:
> 
> - Incorrectly assumed that max_t() was defined despite commit
>    5cf67a6051ea ("tools/include: Add _RET_IP_ and math definitions to
>    kernel.h") not being present
> - Incorrectly assumed that kvm_vm struct members could be directly
>    accessed despite b530eba14c70 ("KVM: selftests: Get rid of
>    kvm_util_internal.h") not being present
> 
> Backport the first commit, as it is simple enough. Work around the lack
> of the second commit by using the accessors to get to the kvm_vm struct
> members.
> 
> Note that the linux-6.0.y backport of commit 05c2224d4b04 ("KVM:
> selftests: Fix number of pages for memory slot in
> memslot_modification_stress_test") is fine because the two prerequisite
> commits, mentioned above, are both present in v6.0.
> 
> Tyler
> 
> Karolina Drobnik (1):
>    tools/include: Add _RET_IP_ and math definitions to kernel.h
> 
> Tyler Hicks (Microsoft) (1):
>    KVM: selftests: Fix build regression by using accessor function
> 
>   tools/include/linux/kernel.h                                | 6 ++++++
>   .../selftests/kvm/memslot_modification_stress_test.c        | 2 +-
>   2 files changed, 7 insertions(+), 1 deletion(-)
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>


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

* Re: [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y
  2022-12-23 16:45 ` [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Paolo Bonzini
@ 2022-12-25  3:33   ` Sasha Levin
  0 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2022-12-25  3:33 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Tyler Hicks, gregkh, stable, Shuah Khan, kvm, linux-kselftest,
	linux-kernel, Gavin Shan, Marc Zyngier, Karolina Drobnik,
	Mike Rapoport

On Fri, Dec 23, 2022 at 05:45:44PM +0100, Paolo Bonzini wrote:
>On 12/23/22 01:09, Tyler Hicks wrote:
>>From: "Tyler Hicks" <code@tyhicks.com>
>>
>>The backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of
>>pages for memory slot in memslot_modification_stress_test") broke the
>>build of the KVM selftest memslot_modification_stress_test.c source file
>>in two ways:
>>
>>- Incorrectly assumed that max_t() was defined despite commit
>>   5cf67a6051ea ("tools/include: Add _RET_IP_ and math definitions to
>>   kernel.h") not being present
>>- Incorrectly assumed that kvm_vm struct members could be directly
>>   accessed despite b530eba14c70 ("KVM: selftests: Get rid of
>>   kvm_util_internal.h") not being present
>>
>>Backport the first commit, as it is simple enough. Work around the lack
>>of the second commit by using the accessors to get to the kvm_vm struct
>>members.
>>
>>Note that the linux-6.0.y backport of commit 05c2224d4b04 ("KVM:
>>selftests: Fix number of pages for memory slot in
>>memslot_modification_stress_test") is fine because the two prerequisite
>>commits, mentioned above, are both present in v6.0.
>>
>>Tyler
>>
>>Karolina Drobnik (1):
>>   tools/include: Add _RET_IP_ and math definitions to kernel.h
>>
>>Tyler Hicks (Microsoft) (1):
>>   KVM: selftests: Fix build regression by using accessor function
>>
>>  tools/include/linux/kernel.h                                | 6 ++++++
>>  .../selftests/kvm/memslot_modification_stress_test.c        | 2 +-
>>  2 files changed, 7 insertions(+), 1 deletion(-)
>>
>
>Acked-by: Paolo Bonzini <pbonzini@redhat.com>
>

Queued up, thanks!

-- 
Thanks,
Sasha

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

end of thread, other threads:[~2022-12-25  3:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23  0:09 [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Tyler Hicks
2022-12-23  0:09 ` [PATCH 5.15 1/2] tools/include: Add _RET_IP_ and math definitions to kernel.h Tyler Hicks
2022-12-23  0:09 ` [PATCH 5.15 2/2] KVM: selftests: Fix build regression by using accessor function Tyler Hicks
2022-12-23 16:45 ` [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Paolo Bonzini
2022-12-25  3:33   ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.