From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B50161CC89A; Thu, 22 Aug 2024 15:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724339185; cv=none; b=lFVpbtUohBcPy+Tc5D9lsTuWkLn2eGwFSuNXowWi4jGtiyg7zGpGjJVBjjS6HxXrFEh2Ut/yrMMYlNBQHJhlo+dwg4wqFZVwP5n9FFSic7u0zpUNsBJu1pTaxbwk8y7EE91qiqy1hD5C9lfCzRr9uaL0y6pXNuIyvzW06ZD4k5U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724339185; c=relaxed/simple; bh=QCgSudnWYAHAbhwqPzcmGR64pvLJdT3jGrGJ7AS7PPI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BDe3WhN4OJw3dt0tDh2YRow0tXrHIW2yUfJ6XP47MHBrhrEYi2gNwckRpg95oS8bghGyumaGFBAF90Zwj5TN0d8SpUwoofgFcSCu9vp4fdEgvlKDJpFFeGGQ/tXy6JGOoGhjtdwPoZO4g4n+cWNNJh1E4ThqaekTrQJMvGcykDg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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 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