From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CDFFC3DA4A for ; Thu, 22 Aug 2024 15:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pPKT/Zv2gNwhpwf4dZlcL17udroAZSr1T+7nOoXlcKM=; b=omE/3MvMWciuR3RP1cW395NYVw zJNgVZiYbydEoDexO70HTrA9POWQlwKs15g5WbbHbxWl/iMoEi8g3o5m1ixT9oL/mf7rxVUS86Bpc Y3SMcraA9BxqFOG1DCZPdqwtKP9nHSQh0pLPcDCvSxQbzbmWIllVsTWRnzYCMZn0iuqjvQT2ievYw 47v1oejoGTh9/CX9lsdwH277hOYVQRQ8dOv4735YF5MJpTyagJCcsvAvpXSzLtIrT59+PX2QKfsvA xJJHZULR6mhlxtF/Xe+uBHEO7yAK57577XYket1az0WN5hzGtouavHxHpm88iA0QOdVOTtyPn51Zj T5yH81og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh9Pu-0000000DHJD-2KKR; Thu, 22 Aug 2024 15:08:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh9OJ-0000000DGxA-39Zl for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 15:06:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 51FF5DA7; Thu, 22 Aug 2024 08:06:49 -0700 (PDT) Received: from [10.57.85.214] (unknown [10.57.85.214]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 608E83F58B; Thu, 22 Aug 2024 08:06:18 -0700 (PDT) Message-ID: <282a765a-3b42-4175-8d9f-58456d13a37d@arm.com> Date: Thu, 22 Aug 2024 16:06:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 18/43] arm64: RME: Handle realm enter/exit To: "Aneesh Kumar K.V" , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun References: <20240821153844.60084-1-steven.price@arm.com> <20240821153844.60084-19-steven.price@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240822_080623_870994_E11D03C3 X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 22/08/2024 05:04, Aneesh Kumar K.V wrote: > Steven Price writes: > > .... > >> +static int rec_exit_ripas_change(struct kvm_vcpu *vcpu) >> +{ >> + struct kvm *kvm = vcpu->kvm; >> + struct realm *realm = &kvm->arch.realm; >> + struct realm_rec *rec = &vcpu->arch.rec; >> + unsigned long base = rec->run->exit.ripas_base; >> + unsigned long top = rec->run->exit.ripas_top; >> + unsigned long ripas = rec->run->exit.ripas_value & 1; >> + unsigned long top_ipa; >> + int ret = -EINVAL; >> + >> + if (realm_is_addr_protected(realm, base) && >> + realm_is_addr_protected(realm, top - 1)) { >> + kvm_mmu_topup_memory_cache(&vcpu->arch.mmu_page_cache, >> + kvm_mmu_cache_min_pages(vcpu->arch.hw_mmu)); >> + write_lock(&kvm->mmu_lock); >> + ret = realm_set_ipa_state(vcpu, base, top, ripas, &top_ipa); >> + write_unlock(&kvm->mmu_lock); >> + } >> + >> + WARN(ret && ret != -ENOMEM, >> + "Unable to satisfy SET_IPAS for %#lx - %#lx, ripas: %#lx\n", >> + base, top, ripas); >> + >> + /* Exit to VMM to complete the change */ >> + kvm_prepare_memory_fault_exit(vcpu, base, top_ipa - base, false, false, >> + ripas == 1); >> + >> + return 0; >> +} >> + > > arch/arm64/kvm/rme-exit.c:100:6: warning: variable 'top_ipa' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] > if (realm_is_addr_protected(realm, base) && > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/arm64/kvm/rme-exit.c:114:44: note: uninitialized use occurs here > kvm_prepare_memory_fault_exit(vcpu, base, top_ipa - base, false, false, > ^~~~~~~ I'm not sure why I didn't notice this before, if the condition is false then we're hitting the WARN (i.e. this shouldn't happen), but I should fix that up to handle the situation better. Steve