Message ID | 20231208184628.2297994-1-pbonzini@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5650191vqy; Fri, 8 Dec 2023 10:46:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJ2Ar6frKiMnD9Z5tbzMrICYE7aLIwnPrl9M0ZEBR0jOYhCgb5ADJS0TXkGKk+0ew1DhRU X-Received: by 2002:a05:6a20:7fa0:b0:190:28d1:8e0b with SMTP id d32-20020a056a207fa000b0019028d18e0bmr596871pzj.35.1702061198648; Fri, 08 Dec 2023 10:46:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702061198; cv=none; d=google.com; s=arc-20160816; b=l13FWSIo0ONGovlYGTRyzVZPLbxUV17CRU8/zMgsqnmYhhrhKZzJ20MOVEU/ItY4wr 0svxNe7080xC4cCxyiMt2xGMALuejERVSwgj5OoCqFYdaj7bSem3g7vKpeW4o+j6Ut47 GAV7khKbmM//1Hu2jksRH4lMDjUZUjw5A4vxMRWUyOCA4frlUTu0jRDhqID/QAxYIBH0 0aiNQAL3pL1vpmdsC4Eq/qks/8TDOMWcJ2rNDYmdTytUro6FMQ4yC1DYoCFoHuBIWwJH 13ydA3anlABkOBU0kfxA/MoLUSgfRuYbBfdCXfLthVmctP4Mj2zX1m+8vXSJYmFHygLy tZOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=oyg9tG3YUMXYWf0fhNWSelQCkgGQnlr8E+uOxhosRhg=; fh=4N0ilCeWNPUMy3p+fwQEcpDcSktLq8IMxbqwLAweA1k=; b=s/Cy5kg6MK6QBC+QcIGls7USsQKOLpOJVi/aDX3dQ7d5lIkXYDwBIRSbm/L1EwWm6W Lr6W77MLTGmpmgWIBm8drYrc5ONyj+bHfcjcmRGBddVmRiHv93OMqdD2L/f9v6hInSoA FUYtkDhCyTxQklkkV3DMq+sWDzs5k88VxDySaa9KpKb2ez3NLqKqbt5Hfwt5vOrk91h3 UqsYWZtuScFkTD/qNRfbLEsS4q4npu/Jb822FRcRw58hy0ZD8juaWL0EHHqolXgDLlRx A8HA+ecJ4n7RhwbdWoOjRTZaEquq9jrnn39RCMaXIIunZ8H5xGep1v0ZCtmJGAs5X1RB tDEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XR7Bm6Pg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f15-20020a65628f000000b005c66e4949a8si1917026pgv.246.2023.12.08.10.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 10:46:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XR7Bm6Pg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8E79181DC637; Fri, 8 Dec 2023 10:46:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229938AbjLHSq0 (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Fri, 8 Dec 2023 13:46:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjLHSqZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 8 Dec 2023 13:46:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6239E0 for <linux-kernel@vger.kernel.org>; Fri, 8 Dec 2023 10:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702061190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oyg9tG3YUMXYWf0fhNWSelQCkgGQnlr8E+uOxhosRhg=; b=XR7Bm6Pg+TPdXvTFRk8PjklNQFG1ePf70kARko8MsD7Iu/1BcXnItSxB859FB7qiDSgOfW 7An+QD2LSdqtmYmmnoytNY6CIpvPlkN5na+jYtf7++chCOBshZ/10tPj60ud6z/NdKnjJb +wsrsC3JAhKFcFvT4HtpjafR+Vs/pvA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-KwE-bmmkNByZfmLRbef5QA-1; Fri, 08 Dec 2023 13:46:29 -0500 X-MC-Unique: KwE-bmmkNByZfmLRbef5QA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7E91101A52A; Fri, 8 Dec 2023 18:46:28 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id B03BD112131D; Fri, 8 Dec 2023 18:46:28 +0000 (UTC) From: Paolo Bonzini <pbonzini@redhat.com> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH] KVM: selftests: fix supported_flags for aarch64 Date: Fri, 8 Dec 2023 13:46:28 -0500 Message-Id: <20231208184628.2297994-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 10:46:35 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784740523584363439 X-GMAIL-MSGID: 1784740523584363439 |
Series |
KVM: selftests: fix supported_flags for aarch64
|
|
Commit Message
Paolo Bonzini
Dec. 8, 2023, 6:46 p.m. UTC
KVM/Arm supports readonly memslots; fix the calculation of
supported_flags in set_memory_region_test.c, otherwise the
test fails.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tools/testing/selftests/kvm/set_memory_region_test.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Fri, Dec 08, 2023, Paolo Bonzini wrote: > KVM/Arm supports readonly memslots; fix the calculation of > supported_flags in set_memory_region_test.c, otherwise the > test fails. You got beat by a few hours, and by a better solution ;-) https://lore.kernel.org/all/20231208033505.2930064-1-shahuang@redhat.com > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > tools/testing/selftests/kvm/set_memory_region_test.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c > index 6637a0845acf..dfd1d1e22da3 100644 > --- a/tools/testing/selftests/kvm/set_memory_region_test.c > +++ b/tools/testing/selftests/kvm/set_memory_region_test.c > @@ -333,9 +333,11 @@ static void test_invalid_memory_region_flags(void) > struct kvm_vm *vm; > int r, i; > > -#ifdef __x86_64__ > +#if defined __aarch64__ || defined __x86_64__ > supported_flags |= KVM_MEM_READONLY; > +#endif > > +#ifdef __x86_64__ > if (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SW_PROTECTED_VM)) > vm = vm_create_barebones_protected_vm(); > else > -- > 2.39.1 >
On 12/9/23 03:29, Sean Christopherson wrote: > On Fri, Dec 08, 2023, Paolo Bonzini wrote: >> KVM/Arm supports readonly memslots; fix the calculation of >> supported_flags in set_memory_region_test.c, otherwise the >> test fails. > > You got beat by a few hours, and by a better solution ;-) > > https://lore.kernel.org/all/20231208033505.2930064-1-shahuang@redhat.com Better but also wrong---and my patch has the debatable merit of more clearly exposing the wrongness. Testing individual architectures is bad, but testing __KVM_HAVE_READONLY_MEM makes the test fail when running a new test on an old kernel. This scenario of course will fail when the test detects a bug, but readonly memory is just new functionality (think of the case where RISC-V starts defining __KVM_HAVE_READONLY_MEM in the future). For new functionality, the right thing to do is one of 1) skip the whole test 2) skip the individual test case 3) code the test to adapt to the old kernel. The third choice is rarely possible, but this is one of the cases in which it _is_ possible. So, the only good way to do this is to get _all_ supported_flags from KVM_CHECK_EXTENSION(KVM_CAP_USER_MEMORY2). We can change the value returned by KVM_CHECK_EXTENSION because KVM_CAP_USER_MEMORY2 has not been included in any released kernel. Calling KVM_CHECK_EXTENSION subsumes supported_flags |= KVM_MEM_READONLY; if (kvm_check_cap(KVM_CAP_MEMORY_ATTRIBUTES) & KVM_MEMORY_ATTRIBUTE_PRIVATE) supported_flags |= KVM_MEM_GUEST_MEMFD; and v2_only_flags would be defined as const uint32_t v2_only_flags = ~(KVM_MEM_LOG_DIRTY_PAGES | KVM_MEM_READONLY); (not guaranteed to work in the future, but good enough since new KVM_MEM_* flags are a very rare occurrence). Then, the test checks that the supported flags are consistent with the value returned by KVM_CHECK_EXTENSION. Shaoqin, would you give it a shot? Thanks, Paolo > >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> >> --- >> tools/testing/selftests/kvm/set_memory_region_test.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c >> index 6637a0845acf..dfd1d1e22da3 100644 >> --- a/tools/testing/selftests/kvm/set_memory_region_test.c >> +++ b/tools/testing/selftests/kvm/set_memory_region_test.c >> @@ -333,9 +333,11 @@ static void test_invalid_memory_region_flags(void) >> struct kvm_vm *vm; >> int r, i; >> >> -#ifdef __x86_64__ >> +#if defined __aarch64__ || defined __x86_64__ >> supported_flags |= KVM_MEM_READONLY; >> +#endif >> >> +#ifdef __x86_64__ >> if (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SW_PROTECTED_VM)) >> vm = vm_create_barebones_protected_vm(); >> else >> -- >> 2.39.1 >>
On Tue, Dec 12, 2023, Paolo Bonzini wrote: > On 12/9/23 03:29, Sean Christopherson wrote: > > On Fri, Dec 08, 2023, Paolo Bonzini wrote: > > > KVM/Arm supports readonly memslots; fix the calculation of > > > supported_flags in set_memory_region_test.c, otherwise the > > > test fails. > > > > You got beat by a few hours, and by a better solution ;-) > > > > https://lore.kernel.org/all/20231208033505.2930064-1-shahuang@redhat.com > > Better but also wrong---and my patch has the debatable merit of more > clearly exposing the wrongness. Testing individual architectures is bad, > but testing __KVM_HAVE_READONLY_MEM makes the test fail when running a new > test on an old kernel. But we already crossed that bridge and burned it for good measure by switching to KVM_SET_USER_MEMORY_REGION2, i.e. as of commit 8d99e347c097 ("KVM: selftests: Convert lib's mem regions to KVM_SET_USER_MEMORY_REGION2") selftests built against a new kernel can't run on an old kernel. Building KVM selftests requires kernel headers, so while not having a hard requirement that the uapi headers are fresh would be nice, I don't think it buys all that much. If we wanted to assert that x86, arm64, etc. enumerate __KVM_HAVE_READONLY_MEM, i.e. ensure that read-only memory is supported as expected, then that can be done as a completely unrelated test. IMO, one of the big selling points of selftests over KUT is that we can punt on supporting old kernels since selftests are in-tree. I don't think it's at all unreasonable to require that selftests be built against the target kernel, and by doing so we can signficantly reduce the maintenance burden. The kernel needs to be backwards compatibile, but I don't see why selftests need to be backwards compatible.
On 12/13/23 18:21, Sean Christopherson wrote: > On Tue, Dec 12, 2023, Paolo Bonzini wrote: >> On 12/9/23 03:29, Sean Christopherson wrote: >>> On Fri, Dec 08, 2023, Paolo Bonzini wrote: >>>> KVM/Arm supports readonly memslots; fix the calculation of >>>> supported_flags in set_memory_region_test.c, otherwise the >>>> test fails. >>> >>> You got beat by a few hours, and by a better solution ;-) >>> >>> https://lore.kernel.org/all/20231208033505.2930064-1-shahuang@redhat.com >> >> Better but also wrong---and my patch has the debatable merit of more >> clearly exposing the wrongness. Testing individual architectures is bad, >> but testing __KVM_HAVE_READONLY_MEM makes the test fail when running a new >> test on an old kernel. > > But we already crossed that bridge and burned it for good measure by switching > to KVM_SET_USER_MEMORY_REGION2, i.e. as of commit > > 8d99e347c097 ("KVM: selftests: Convert lib's mem regions to KVM_SET_USER_MEMORY_REGION2") > > selftests built against a new kernel can't run on an old kernel. Building KVM > selftests requires kernel headers, so while not having a hard requirement that > the uapi headers are fresh would be nice, I don't think it buys all that much. > > If we wanted to assert that x86, arm64, etc. enumerate __KVM_HAVE_READONLY_MEM, > i.e. ensure that read-only memory is supported as expected, then that can be done > as a completely unrelated test. selftests have the luxury of having sync-ed kernel headers, but in general userspace won't, and that means __KVM_HAVE_READONLY_MEM would be a very poor userspace API. Fortunately it has "__" so it is not userspace API at all, and I don't want selftests to treat it as one. > IMO, one of the big selling points of selftests over KUT is that we can punt on > supporting old kernels since selftests are in-tree. I don't think it's at all > unreasonable to require that selftests be built against the target kernel, and > by doing so we can signficantly reduce the maintenance burden. The kernel needs > to be backwards compatibile, but I don't see why selftests need to be backwards > compatible. It does help sometimes to be able to run old tests on new kernel or vice versa. So even without making that a requirement, it is a nice thing to have whenever possible. Paolo
On Wed, Dec 13, 2023, Paolo Bonzini wrote: > On 12/13/23 18:21, Sean Christopherson wrote: > > On Tue, Dec 12, 2023, Paolo Bonzini wrote: > > > On 12/9/23 03:29, Sean Christopherson wrote: > > > > On Fri, Dec 08, 2023, Paolo Bonzini wrote: > > > > > KVM/Arm supports readonly memslots; fix the calculation of > > > > > supported_flags in set_memory_region_test.c, otherwise the > > > > > test fails. > > > > > > > > You got beat by a few hours, and by a better solution ;-) > > > > > > > > https://lore.kernel.org/all/20231208033505.2930064-1-shahuang@redhat.com > > > > > > Better but also wrong---and my patch has the debatable merit of more > > > clearly exposing the wrongness. Testing individual architectures is bad, > > > but testing __KVM_HAVE_READONLY_MEM makes the test fail when running a new > > > test on an old kernel. > > > > But we already crossed that bridge and burned it for good measure by switching > > to KVM_SET_USER_MEMORY_REGION2, i.e. as of commit > > > > 8d99e347c097 ("KVM: selftests: Convert lib's mem regions to KVM_SET_USER_MEMORY_REGION2") > > > > selftests built against a new kernel can't run on an old kernel. Building KVM > > selftests requires kernel headers, so while not having a hard requirement that > > the uapi headers are fresh would be nice, I don't think it buys all that much. > > > > If we wanted to assert that x86, arm64, etc. enumerate __KVM_HAVE_READONLY_MEM, > > i.e. ensure that read-only memory is supported as expected, then that can be done > > as a completely unrelated test. > > selftests have the luxury of having sync-ed kernel headers, but in general > userspace won't, and that means __KVM_HAVE_READONLY_MEM would be a very poor > userspace API. Fortunately it has "__" so it is not userspace API at all, > and I don't want selftests to treat it as one. Wait, what? How does double underscores exempt it from being uAPI? AIUI, the C standard effectively ensures that userspace won't define/declare symbols with double underscores, i.e. ensures there won't be conflicts. But pretty much all of the kernel-defined types are prefixed with "__", e.g. __u8 and friends, so I don't see how prefixing with "__" exempts something from becoming uAPI. I completely agree that __KVM_HAVE_READONLY_MEM shouldn't be uAPI, but then it really, really shouldn't be defined in arch/x86/include/uapi/asm/kvm.h.
On Wed, Dec 13, 2023 at 7:15 PM Sean Christopherson <seanjc@google.com> wrote: > > selftests have the luxury of having sync-ed kernel headers, but in general > > userspace won't, and that means __KVM_HAVE_READONLY_MEM would be a very poor > > userspace API. Fortunately it has "__" so it is not userspace API at all, > > and I don't want selftests to treat it as one. > > Wait, what? How does double underscores exempt it from being uAPI? AIUI, the C > standard effectively ensures that userspace won't define/declare symbols with > double underscores, i.e. ensures there won't be conflicts. But pretty much all > of the kernel-defined types are prefixed with "__", e.g. __u8 and friends, so I > don't see how prefixing with "__" exempts something from becoming uAPI. Userspace is generally not supposed to know that double underscore symbols exist, though in some cases it has to (see for example _UFFDIO_*). Looking at yesterday's patch from Dionna, userspace is very much not supposed to use _BITUL, and even less so for _UL. In particular, __KVM_HAVE_* symbols are meant to mask definitions in include/uapi/linux/kvm.h. __KVM_HAVE_READONLY_MEM was a very misguided mean to define KVM_CAP_READONLY_MEM only on architectures where it could have possibly be true (see commit 0f8a4de3e088, "KVM: Unconditionally export KVM_CAP_READONLY_MEM", 2014-08-29). Which does not make sense at all, as the commit message points out. So I'm willing to test my chances, kill it and see if anyone complains (while crossing fingers that Google and Amazon don't :)). Paolo > I completely agree that __KVM_HAVE_READONLY_MEM shouldn't be uAPI, but then it > really, really shouldn't be defined in arch/x86/include/uapi/asm/kvm.h. > On Wed, Dec 13, 2023 at 7:15 PM Sean Christopherson <seanjc@google.com> wrote: > > On Wed, Dec 13, 2023, Paolo Bonzini wrote: > > On 12/13/23 18:21, Sean Christopherson wrote: > > > On Tue, Dec 12, 2023, Paolo Bonzini wrote: > > > > On 12/9/23 03:29, Sean Christopherson wrote: > > > > > On Fri, Dec 08, 2023, Paolo Bonzini wrote: > > > > > > KVM/Arm supports readonly memslots; fix the calculation of > > > > > > supported_flags in set_memory_region_test.c, otherwise the > > > > > > test fails. > > > > > > > > > > You got beat by a few hours, and by a better solution ;-) > > > > > > > > > > https://lore.kernel.org/all/20231208033505.2930064-1-shahuang@redhat.com > > > > > > > > Better but also wrong---and my patch has the debatable merit of more > > > > clearly exposing the wrongness. Testing individual architectures is bad, > > > > but testing __KVM_HAVE_READONLY_MEM makes the test fail when running a new > > > > test on an old kernel. > > > > > > But we already crossed that bridge and burned it for good measure by switching > > > to KVM_SET_USER_MEMORY_REGION2, i.e. as of commit > > > > > > 8d99e347c097 ("KVM: selftests: Convert lib's mem regions to KVM_SET_USER_MEMORY_REGION2") > > > > > > selftests built against a new kernel can't run on an old kernel. Building KVM > > > selftests requires kernel headers, so while not having a hard requirement that > > > the uapi headers are fresh would be nice, I don't think it buys all that much. > > > > > > If we wanted to assert that x86, arm64, etc. enumerate __KVM_HAVE_READONLY_MEM, > > > i.e. ensure that read-only memory is supported as expected, then that can be done > > > as a completely unrelated test. > > > > selftests have the luxury of having sync-ed kernel headers, but in general > > userspace won't, and that means __KVM_HAVE_READONLY_MEM would be a very poor > > userspace API. Fortunately it has "__" so it is not userspace API at all, > > and I don't want selftests to treat it as one. > > Wait, what? How does double underscores exempt it from being uAPI? AIUI, the C > standard effectively ensures that userspace won't define/declare symbols with > double underscores, i.e. ensures there won't be conflicts. But pretty much all > of the kernel-defined types are prefixed with "__", e.g. __u8 and friends, so I > don't see how prefixing with "__" exempts something from becoming uAPI. > > I completely agree that __KVM_HAVE_READONLY_MEM shouldn't be uAPI, but then it > really, really shouldn't be defined in arch/x86/include/uapi/asm/kvm.h. >
diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c index 6637a0845acf..dfd1d1e22da3 100644 --- a/tools/testing/selftests/kvm/set_memory_region_test.c +++ b/tools/testing/selftests/kvm/set_memory_region_test.c @@ -333,9 +333,11 @@ static void test_invalid_memory_region_flags(void) struct kvm_vm *vm; int r, i; -#ifdef __x86_64__ +#if defined __aarch64__ || defined __x86_64__ supported_flags |= KVM_MEM_READONLY; +#endif +#ifdef __x86_64__ if (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SW_PROTECTED_VM)) vm = vm_create_barebones_protected_vm(); else