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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5527BC4167D for ; Thu, 2 Nov 2023 18:13:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377180AbjKBSNG (ORCPT ); Thu, 2 Nov 2023 14:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235478AbjKBSM5 (ORCPT ); Thu, 2 Nov 2023 14:12:57 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11FAD3C02; Thu, 2 Nov 2023 11:01:59 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4083f613272so10884975e9.1; Thu, 02 Nov 2023 11:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698948115; x=1699552915; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:from:to:cc:subject:date:message-id:reply-to; bh=s9v7fSZdeM5lhEwx+RSQKLoMZAxQbqm89rXIxNUF1qU=; b=I/I4KR3/t4STPpazSdJQC5wM7BplxiqHhYNo1M6bljYUVoYlEDfuO+9fHyA+ktSMFg Bih9oVYwMthfvmUHawyXaP+HZpNYdUJP9oYxQ+oH/V0bmiX6s5tSizM8X8h+ccuIlG93 CNeSPZuFL+IUDOupMZbwsRBKxDl9PiW38sOqrCFfMLvmko97TDK88pDudR4rBmOoxiUh 3quLuAPWSxxIK6X05Lb1zyzfff42fhV7Jax3/m8RqKMVwL3Hv6leYNhqQW3kcTeSBkpG XMsqtdZUQFef+WwqGiaBfxOc1TIPLJDiFULZp7mIORtlwRTb8k744Gbce5uQosuNQCJc v1ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698948115; x=1699552915; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s9v7fSZdeM5lhEwx+RSQKLoMZAxQbqm89rXIxNUF1qU=; b=A8rZEYNU0n7IWt9SwUCoFRFU9y1+8ySGrmi+ftWKy09THzDR1a8g1AD47hWQqIsAt5 wAqPaWFp0Wc4UPAJrj8VSTGysNAPR5JiKi0wB79xX5kE4aM6UHzDLCLmcKpTJDPvUfYg cNE+LZ0WT5h2lgcIXocFknxcy9eLgHuUqbNs2AN40yURw2755a8qolhfOXfcd/9yVX6p Gco8fXr1dHCVCm+8wZJEXqXcOu1Jh4NrOCu2FSyrK6j/y6FPSszCQKrGW+3gHHL8rgkY w92/SLA+FSEs50dF8/yWUDYI6vdermwqStFEsMwDj/13mZHLUi73RWQAlxHyZB0t7qyu nwjQ== X-Gm-Message-State: AOJu0YwlL5jnwQgy+w5Eixn2Z2T5TERFmk9nij6bg7OzrWrQ+XzK08QT uWVx43aCekuQjhGLi9I3b44= X-Google-Smtp-Source: AGHT+IEZGqW/vxesUw1UMzhtf2vnCkMbF2yFSaqWJA+rHOg1Bsq4xatZmZCYotCXR2brSZnSlLimqg== X-Received: by 2002:a05:6000:2c7:b0:32d:d2ef:b0e4 with SMTP id o7-20020a05600002c700b0032dd2efb0e4mr19025433wry.0.1698948114541; Thu, 02 Nov 2023 11:01:54 -0700 (PDT) Received: from [192.168.14.38] (54-240-197-227.amazon.com. [54.240.197.227]) by smtp.gmail.com with ESMTPSA id b11-20020a5d4d8b000000b0032d8354fb43sm3018823wru.76.2023.11.02.11.01.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Nov 2023 11:01:43 -0700 (PDT) From: Paul Durrant X-Google-Original-From: Paul Durrant Message-ID: <8c6f06ae-d1d3-40ea-9bed-8ca949eaff5f@xen.org> Date: Thu, 2 Nov 2023 18:01:35 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: paul@xen.org Subject: Re: [PATCH v7 05/11] KVM: pfncache: allow a cache to be activated with a fixed (userspace) HVA Content-Language: en-US To: Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Durrant , David Woodhouse , Paolo Bonzini , David Woodhouse References: <20231002095740.1472907-1-paul@xen.org> <20231002095740.1472907-6-paul@xen.org> Organization: Xen Project In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31/10/2023 23:49, Sean Christopherson wrote: > On Mon, Oct 02, 2023, Paul Durrant wrote: >> diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h >> index 6f4737d5046a..d49946ee7ae3 100644 >> --- a/include/linux/kvm_types.h >> +++ b/include/linux/kvm_types.h >> @@ -64,7 +64,7 @@ struct gfn_to_hva_cache { >> >> struct gfn_to_pfn_cache { >> u64 generation; >> - gpa_t gpa; >> + u64 addr; > > Holy moly, we have unions for exactly this reason. > > union { > gpa_t gpa; > unsigned long addr; > }; > > But that's also weird and silly because it's basically the exact same thing as > "uhva". If "uhva" stores the full address instead of the page-aligned address, > then I don't see a need for unionizing the gpa and uhva. > Ok, I think that'll be more invasive but I'll see how it looks. > kvm_xen_vcpu_get_attr() should darn well explicitly check that the gpc stores > the correct type and not bleed ABI into the gfn_to_pfn_cache implementation. > I guess if we leave gpa alone and make it INVALID_GPA for caches initialized using an HVA then that can be checked. Is that what you mean here? > If there's a true need for a union, the helpers should WARN. > >> +unsigned long kvm_gpc_hva(struct gfn_to_pfn_cache *gpc) >> +{ >> + return !gpc->addr_is_gpa ? gpc->addr : 0; > > '0' is a perfectly valid address. Yeah, practically speaking '0' can't be used > these days, but we already have KVM_HVA_ERR_BAD. If y'all want to use the for the > Xen ABI, then so be it. But the common helpers need to use a sane value. Ok. Paul