Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6527684rwb; Mon, 12 Dec 2022 03:09:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf6AqZrL58qCLw6iMkbr8PjjJ6O9msXXTUVOevT6ekYcd8rfYXRpVHf7p7ZRZTw5pr3M1r/Q X-Received: by 2002:a05:6402:2986:b0:45c:835b:7991 with SMTP id eq6-20020a056402298600b0045c835b7991mr12617695edb.18.1670843392298; Mon, 12 Dec 2022 03:09:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670843392; cv=none; d=google.com; s=arc-20160816; b=qbCyzAEDKhRb+x5v1dqbXccrGpIBMGITzKzC5fPFJbq/A8hZw4730jbKSkrPb0YVyJ R6u+Zv29+M1fz2IB5syzyA1N2VC6oYp1YJmaLJ1Pc/Lrq0ytncfhU0G3UDGyfi7vrSaB K29uHtroafmEzHj+/Wq1/xOKkXe9rgrCpZG/CfyXSsJj7ntMAIeq0RmNiqVyquVPDY4h BavpMUygWUDgaNi1E2Tp7fLvRUVEgu+Se2RfsUpBrt5YDQ6A/GPYnKcpUP9GsJm6Dti9 BJmselfl2vw5rxlOEMyRQqCjRg9oRWIiNd4JPYyoelv65nw0JXJlRr0leFLc8uCcC0jb hYlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=KFD4bXF9HfKCTB2bqwvpTx8dBPmnhTdXw6WlgJmCRVE=; b=R5Pbvuqbq342rknavn4CqsXKrMfJssK0a5OHUNnH9vLv8L3lv94oI6UKVADOsDW2bT gd67/o5kYtVGDhK99y8jBd2Jf7MpxgFVRo6TdryDAoKcqYVPYVNWV/zpGxstOiHHDGmK OFCY17KnCb/8koX+aZp5HO2fa/UqKYHlbxTaxNxN9QVl+HNILeg34ynaC3IT9EaVreeW 1t5oHEUa2TGeHyiDQbRS/VGKddl53trH24isBSQvm/oEHvmoJ1VH+jVtvj4QTaM6zcaL GV1r8g/r8Vb6vBy4qjs05imdBXbUtfOQOP+bS5Q2LXZS03aCDtKTc/rxrSAMk59l/TZ7 EmqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="KKucQ/Bu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a056402280d00b0046b7410c015si8391217ede.18.2022.12.12.03.09.31; Mon, 12 Dec 2022 03:09:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="KKucQ/Bu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232128AbiLLKp3 (ORCPT + 75 others); Mon, 12 Dec 2022 05:45:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232149AbiLLKll (ORCPT ); Mon, 12 Dec 2022 05:41:41 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB92F62E6 for ; Mon, 12 Dec 2022 02:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670841300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFD4bXF9HfKCTB2bqwvpTx8dBPmnhTdXw6WlgJmCRVE=; b=KKucQ/Bu1/lv68mwDOoBIY0ErKwJz5aWWGszCMisnn4XqtI7lpbX3ffgf1h10KJRU8Mq4n Ql1vggxmsQk18NWTyXCCeafaRFLGeOrnyVdVhzS68Q6Io8GktMWjEC2yIQ839yZLViP/MS 6VrEyYStWngn2ieUj9pcU8omh0ecUKo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-169-y6UFkkqyOquK5bJOzEgwlQ-1; Mon, 12 Dec 2022 05:34:59 -0500 X-MC-Unique: y6UFkkqyOquK5bJOzEgwlQ-1 Received: by mail-wm1-f70.google.com with SMTP id j2-20020a05600c1c0200b003cf7397fc9bso3165491wms.5 for ; Mon, 12 Dec 2022 02:34:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KFD4bXF9HfKCTB2bqwvpTx8dBPmnhTdXw6WlgJmCRVE=; b=RjvnSA6ClEjCF4VuYD78r7r6kEyG4V8vLNqLnYQJqr3gzZA8d43WyxvCdtQaiXSy9w d4QO6Cb/bDrNkkT9+ML2BvBwyqwWiz+TSWGx1C+kdW4ZcJqNXYIHmnY6f7p0+g+th/p9 G7gplC1x2yJttPn6tw14AAnMq/hhAEISEkcO340Nh+Mx2xKMKLpccz7Z3EAhFTX2JXni ZWRru+FT4Q5mnLGDCRw7qVzesFWyLaX7Q5Lvc79E3CLgOuJEnFa1lsog3stEWcWLvmAL 8UL2NkZ2Fp9SV+qiTaGehdCvzszfTUbqT6ECsoXQL0enDrWH+6uQdcCkTJWCKrYNAbIJ MbEA== X-Gm-Message-State: ANoB5pm1jTkH1htYn+Gae2vsq98IBVtcUi4G+zhRFC9AnCKXoJ1Pnn/3 i6GZ0bm8m5nenQuTYTm76ISCotrEACmUjiLvKfhfMjgkP9nsfjVBwhCRQvje+pZ3CxlITnuOGxc JvoGc81hlM21Vhm+SmFfedlkr X-Received: by 2002:a5d:4888:0:b0:232:be5d:5ecc with SMTP id g8-20020a5d4888000000b00232be5d5eccmr9224036wrq.35.1670841298283; Mon, 12 Dec 2022 02:34:58 -0800 (PST) X-Received: by 2002:a5d:4888:0:b0:232:be5d:5ecc with SMTP id g8-20020a5d4888000000b00232be5d5eccmr9224016wrq.35.1670841298004; Mon, 12 Dec 2022 02:34:58 -0800 (PST) Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id bn1-20020a056000060100b00242269c8b8esm8603207wrb.25.2022.12.12.02.34.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Dec 2022 02:34:57 -0800 (PST) Message-ID: <322454c7-0a3b-e055-2405-f485fa149e7a@redhat.com> Date: Mon, 12 Dec 2022 11:34:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v2 4/7] KVM: selftests: Correctly initialize the VA space for TTBR0_EL1 Content-Language: en-US To: Oliver Upton , Marc Zyngier , James Morse , Alexandru Elisei , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, Ricardo Koller , Sean Christopherson , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221209015307.1781352-1-oliver.upton@linux.dev> <20221209015307.1781352-5-oliver.upton@linux.dev> From: Paolo Bonzini In-Reply-To: <20221209015307.1781352-5-oliver.upton@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/9/22 02:53, Oliver Upton wrote: > @@ -268,17 +305,17 @@ struct kvm_vm *____vm_create(enum vm_guest_mode mode) > #ifdef __aarch64__ > if (vm->pa_bits != 40) > vm->type = KVM_VM_TYPE_ARM_IPA_SIZE(vm->pa_bits); > + > + /* selftests use TTBR0 only, meaning there is a single VA region. */ > + vm->has_split_va_space = false; > +#else > + vm->has_split_va_space = true; > #endif > Even though there happens to be already a suitable #ifdef, I don't really like them and don't think there should be a new bool unless something else uses it. However, the new comment is very useful, so I added it to kvm_util.c as follows: /testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 759a45540108..56d5ea949cbb 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -186,6 +186,15 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = { _Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params) == NUM_VM_MODES, "Missing new mode params?"); +/* + * Initializes vm->vpages_valid to match the canonical VA space of the + * architecture. + * + * The default implementation is valid for architectures which split the + * range addressed by a single page table into a low and high region + * based on the MSB of the VA. On architectures with this behavior + * the VA region spans [0, 2^(va_bits - 1)), [-(2^(va_bits - 1), -1]. + */ __weak void vm_vaddr_populate_bitmap(struct kvm_vm *vm) { sparsebit_set_num(vm->vpages_valid,