Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp644784lqp; Fri, 5 Apr 2024 05:01:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUlYURATaXUQnbE1eP7TkxJYTDuIV8K+n5rDa6+3n3MoOUbs4cv/+aH9HGLpupenpZQ4kDGG5WM7eBpSazNS80//T5dQsO5G11xeYtOTg== X-Google-Smtp-Source: AGHT+IF7NdTuJ7erlmy7lfHMNFaa3dG5LzXTFISwINCT8AgaaNMpB6P2Q8nzjdpSCjI8oJcixmVm X-Received: by 2002:a05:6870:968a:b0:22e:bdf5:137b with SMTP id o10-20020a056870968a00b0022ebdf5137bmr1349417oaq.42.1712318505436; Fri, 05 Apr 2024 05:01:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712318505; cv=pass; d=google.com; s=arc-20160816; b=BU4u4E+6sZqDQWfAZhpWy8xui92HnJekfKxa/JTAAOnqzZ51s1AbCTKfHgmZmj3H5/ LmwwLoPPKi/bWGO8B7M4pg9aCHCG9u5dg1rR2zCLFK15tM9PolaATVw0iruipJLrR1Mf Wc2n8pWO74hPDt1no38YD62+l5BHUSGRlEMYN+dWTSdGQs9uHJHmJHEW7wDqvd2oFKzf 8JLbeuLo0NvZaB5A6mym96TCX5pCU723+LLydPyWmUN6xRQ0sraFCDfZZ3KXFZeE+lSX PlYcsYMHpp/2/KmPhzH3Cm9o72SjUCfoAXEX4rAtrdHrvYEhJDrVcpzHNynniGQYRK+A 7gIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yv0f7+ZooceAuz8ErMSH+4jWIomyiUMNQo0xCMMDiy0=; fh=YCRQuBJyLHA0oSN9vPH/JHBu5BmwIwBTWEpMe/R3VUE=; b=HzEt7g54LPUMI3A88gD6mWizxKDoYfVlfrrW4UWqjr8jG0E41qc0W8EgL6h2EOFZO+ aAgwtr2vVW8VtYZnpGCKS+ez9MyGV2KdLWz57aDFqhGue6sHc6HmylWaoye6L6PRj3+T w1UK9Sw3WW/NGuWDg0myjfrlv8IGjADwwmLGyssetj3rFvn3QfVjjz0aaEva+ozovzmf FpA0wBITzRYoj2X2Sj8FgaDrpjXVyOvg/Acmh8Smo+LdGm89HFE1JZgHFX4GtwDrprMH 0Nn00yyFGZlUYP5LJDwuqLtyVSz3Y3WA2BhtvsFHUUnKloM/cdMfLshW7zfkZT1miEsH dmfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VpvmWBPw; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-132942-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y16-20020a05622a121000b00432e9c57318si1580454qtx.390.2024.04.05.05.01.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:01:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132942-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VpvmWBPw; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-132942-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D49101C235FB for ; Fri, 5 Apr 2024 12:01:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B06D716C86B; Fri, 5 Apr 2024 12:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VpvmWBPw" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FB2633989 for ; Fri, 5 Apr 2024 12:01:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712318481; cv=none; b=TOq30Dgyab0HMECCHQT5FeV1c3yQe7+nQ0JBlsNqHk1eSvux07kQUZ2p1bS1dOWs/scSTH+hbKP0pkNcIUa5dJ1UqcS+3m9sTCqAOyYFdZ/i1KYZI/tVr7059U8105dCaLr7onNrzUwdRl0pOUOV8v56QVsSNuSM+EvoWPGwxks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712318481; c=relaxed/simple; bh=FRiRwc90NawBYQ1NhQ/i4LDW0LXM9/iVyn9EgL+Kf4U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sqwYn7QXx5iCzzrfG2Oof/vCQki8M0pA4SG6A/sd/r3Vh0v0gpJU9qFNiHKIGafPJbf8t2o0upMhHjca2ShBRlbKXlOO5fp5aWoJ7UkjIl2MvbznxgirdDTlIOVfLFWKxCTUy8nbr38By32JeqZIida18Psow1T3egNVXATry9M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VpvmWBPw; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712318479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yv0f7+ZooceAuz8ErMSH+4jWIomyiUMNQo0xCMMDiy0=; b=VpvmWBPwdzSKBhmiDjdnOIhLCrID9qkMpb8qZBC2tVVthBDeeavyKGL3LlvAFUkq+HfEvm +cDeps2+xUNT9gDVJjok0es1VWJxlWLuLCmn9sYN72H0dTSuHVoQulR+lIewmjx/rZ68cv h7X0CKRpbj3SmQSBzQmVkQX8cJ00OJ8= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-ngfdyHmUMWaz51M7PYvA0g-1; Fri, 05 Apr 2024 08:01:18 -0400 X-MC-Unique: ngfdyHmUMWaz51M7PYvA0g-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-430b7d8b428so19862951cf.1 for ; Fri, 05 Apr 2024 05:01:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712318478; x=1712923278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yv0f7+ZooceAuz8ErMSH+4jWIomyiUMNQo0xCMMDiy0=; b=WZDGHZM941C6gUQvpsSLbG9U6j1cx3TimurxzF8hRPT/ZdhsqaAOmQVypE7Mj6Epme CGkovYDBNy01yXLRePqJzr4w9v/OKXWF1snkaOGrFsl4mJsee752afJs01+8L6EJkjTp h7oeNjTR8Pa7aVRWtYl4wvegi+Tmap5dzCHvha7x6WhCpEELbKmRd0xJXJHbTrvovkQ0 70FWi0HV3SiiwVXSmKfa0Sird74YMVYijtdGCHdyUu22cGEtAuJaGjMJ3wvBRIKKVUMj rC5hnxhdkkPOLRUAsRrLf11TjHA1oWa3FF4Y+pkt6p1h9N6lzxkJ2fvHiZk8HJ7zsJNz biTg== X-Forwarded-Encrypted: i=1; AJvYcCUJNFynXRoQkbyABPjL27jQUwD3i1P/MbB0lhzY8qsosPul/SXqiAgXE4jOzsCs7hOqMT++N77NVYcksmGx1dSTDDijXk8XcpAbBrWA X-Gm-Message-State: AOJu0YzzUFLlB85NizprSszt45zVsX61lGOO4Rgrk89h4XUhGnbmbq2G UonjkFgkXZGZNfVrhUlH/nxJGYmWsMTq/YbSdMYVv8i+o1JTgmzn0ikOJ+EnPt3D47zPVm+UZxk iNpTrZWHpcRdWJj34MpAn6zdAv2p5REHBRJypEbhQSG/1IDM8xkywFahIH7YG3w== X-Received: by 2002:ac8:5886:0:b0:434:516a:5486 with SMTP id t6-20020ac85886000000b00434516a5486mr976112qta.21.1712318477245; Fri, 05 Apr 2024 05:01:17 -0700 (PDT) X-Received: by 2002:ac8:5886:0:b0:434:516a:5486 with SMTP id t6-20020ac85886000000b00434516a5486mr976080qta.21.1712318476646; Fri, 05 Apr 2024 05:01:16 -0700 (PDT) Received: from rh.redhat.com (p200300c93f4c24001316a1e598258370.dip0.t-ipconnect.de. [2003:c9:3f4c:2400:1316:a1e5:9825:8370]) by smtp.gmail.com with ESMTPSA id fb17-20020a05622a481100b00434383f2518sm679808qtb.87.2024.04.05.05.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:01:16 -0700 (PDT) From: Sebastian Ott To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon Subject: [PATCH 1/4] KVM: arm64: change return value in arm64_check_features() Date: Fri, 5 Apr 2024 14:01:05 +0200 Message-ID: <20240405120108.11844-2-sebott@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405120108.11844-1-sebott@redhat.com> References: <20240405120108.11844-1-sebott@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit arm64_check_features() returns -E2BIG to indicate the register's feature set is a superset of the maximally-allowed register value. The only caller of that function changes this to -EINVAL since that's what userspace expects for invalid register writes. In preparation of adding another caller for arm64_check_features() that would need to do the same conversion just return -EINVAL directly. Signed-off-by: Sebastian Ott --- arch/arm64/kvm/sys_regs.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index c9f4f387155f..131f5b0ca2b9 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1445,7 +1445,7 @@ static s64 kvm_arm64_ftr_safe_value(u32 id, const struct arm64_ftr_bits *ftrp, * considered the safe value regardless For register fields that are not in * writable, only the value in limit is considered the safe value. * - * Return: 0 if all the fields are safe. Otherwise, return negative errno. + * Return: 0 if all the fields are safe. Otherwise, return -EINVAL. */ static int arm64_check_features(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, @@ -1464,7 +1464,7 @@ static int arm64_check_features(struct kvm_vcpu *vcpu, * only safe value is 0. */ if (sysreg_visible_as_raz(vcpu, rd)) - return val ? -E2BIG : 0; + return val ? -EINVAL : 0; ftr_reg = get_arm64_ftr_reg(id); if (!ftr_reg) @@ -1490,12 +1490,12 @@ static int arm64_check_features(struct kvm_vcpu *vcpu, safe_val = kvm_arm64_ftr_safe_value(id, ftrp, f_val, f_lim); if (safe_val != f_val) - return -E2BIG; + return -EINVAL; } /* For fields that are not writable, values in limit are the safe values. */ if ((val & ~mask) != (limit & ~mask)) - return -E2BIG; + return -EINVAL; return 0; } @@ -1840,16 +1840,6 @@ static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, IDREG(vcpu->kvm, id) = val; mutex_unlock(&vcpu->kvm->arch.config_lock); - - /* - * arm64_check_features() returns -E2BIG to indicate the register's - * feature set is a superset of the maximally-allowed register value. - * While it would be nice to precisely describe this to userspace, the - * existing UAPI for KVM_SET_ONE_REG has it that invalid register - * writes return -EINVAL. - */ - if (ret == -E2BIG) - ret = -EINVAL; return ret; } -- 2.42.0