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 3F827C04FFE for ; Wed, 8 May 2024 17:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cyiSKHC0DMMLN0p4iTsHMoltAkXWeKH2qCvQ6gn+19k=; b=waM0TjYw6eX6qe 7ypwwNTDCzbkEAgN3pfMzyNHG8uH/Sj5YnLVC4a38TyBi3vd7Z0kEps4za5pblawI9aUPhYOJrRyT Tu4lMZ8nu/TYGpINwO8Y4TkSh/3bBGujA8pGK/fpMwZ4DTHrjWmYzyUPRDSvqcHJzRyEUl3DZUtkR Zvu7uzIFtSj2ArRl81WeIxL8gkT+wgXeordb4MvRrKozXPsWEX6GP4kdusIhrwNumqncQA8KS2pPm yMnwM0Ly/IlwIYpJolTo67saRJxJ7J1iGgqy+W/Esak1cTfmhE/eoRGubmTHT1E6cYQ5p+RRC+Luu XfwGvWB9ZBMU57HrVgzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4ks5-0000000GJjw-3hdj; Wed, 08 May 2024 17:14:25 +0000 Received: from out-174.mta1.migadu.com ([95.215.58.174]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4ks1-0000000GJgz-258i for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2024 17:14:24 +0000 Date: Wed, 8 May 2024 12:14:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715188457; 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: in-reply-to:in-reply-to:references:references; bh=6IxZhOPdDadbq2l7FGvhIKBCyvx+IxN2FVRGwktrREQ=; b=w07lPKs5zbpy7abTfb8Q0yigvYQbi2GYgcG1djv/eJ+3WV3bdZ5YLw4Ftbf2hNLvM1rEz1 JcbgsIQ5+Ksfn4eT5O7OG+TvwpFmtPCzsVCxGBv4k22+EKjsG+OxK4prJFgflXvV9BpGLY 71jfnpqFlqC4F/PepdW6fJhFyilGJI8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Cornelia Huck Cc: "Russell King (Oracle)" , Marc Zyngier , Catalin Marinas , Will Deacon , James Morse , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: Re: [PATCH RFC] KVM: arm64: allow ID_MMFR4_EL1 to be writable Message-ID: References: <87jzk4h5ir.fsf@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87jzk4h5ir.fsf@redhat.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_101421_967624_6EA8975E X-CRM114-Status: GOOD ( 28.70 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Cornelia, On Wed, May 08, 2024 at 02:06:36PM +0200, Cornelia Huck wrote: > On Thu, May 02 2024, Oliver Upton wrote: > > I think (1) should only be expected of VMMs that want rollback safety, > > i.e. the ability to migrate state back to an older kernel. Our userspace > > initializes vCPUs from a fixed set of feature ID register values that > > prevents VMs on new kernels from picking up new CPU features. > > > > It is quite tedious, but necessary as rollback safety is very much a > > non-goal of the KVM UAPI. > > Depending on your use case, rollback safety might be quite > important... have we ever stated exactly which guarantees the KVM UAPI > is giving? IOW, can someone implementing a VMM look at a doc and see > "oh, if I want to be able to go backwards, I need to be able to deal > with x, y, and z coming up on the new kernel"? The behavior of KVM/arm64 has always been that new VMs get the maximum set of vCPU features supported by KVM / hardware modulo the ones we require explicit opt-in from userspace (e.g. SVE, vPMU). This behavior is described in the arm64 vCPU feature documentation [1]. The biggest benefit of this approach is that new vCPU features can be added without a VMM change, as userspace can just treat the registers in KVM_GET_REG_LIST as an opaque blob of data that needs to be migrated. I'm willing to wager that the set of users who want to migrate state from kernel N -> (N - 1) know the exact CPU definition they want to expose to the guest, and in that case should be using a static set of feature register values matching their intent. Beyond the CPU architecture, KVM presents hypercall features to the VM which userspace can _opt-out_ of on a per-feature basis using the feature bitmap registers described in [2]. Like the feature ID registers, we've preallocated a range of indices to be used for hypercall bitmaps. So if an unexpected bitmap register appears on a new kernel, userspace should write 0 to it to prevent new features from silently creeping in. Prescribing the exact combination of these UAPIs to achieve a rollback-safe feature set is beyond the scope of the KVM documentation and should be determined based on the minimum kernel version that needs to work. [1]: https://docs.kernel.org/virt/kvm/arm/vcpu-features.html#the-id-registers [2]: https://docs.kernel.org/virt/kvm/arm/hypercalls.html > >> I've been bitten before with KVM differences between kernel versions > >> in the past - where the number of registers that userspace sees has > >> changed despite being on the same hardware. > > > > This is intended behavior, as VMs are initialized to the maximum feature > > set KVM is able to support. Forward-compatibility for the set of exposed > > registers is tested, see the get-reg-list selftest. > > I've seen this problem come up as well; if it is clear that this is > something that KVM expects the VMM to handle if needed, that is fine; > should we consider "it's tested in a selftest" as a canonical indicator > of "this is what KVM supports compatibility wise"? It certainly is the level of compatibility that gets actively tested :) The canonical reason for this behavior, though, is that KVM/arm64 defaults to the maximum-possible feature set as discussed above. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel