Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp184851lqf; Fri, 26 Apr 2024 03:51:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUAFUYjWX2OSw4wpTA7hJg8kSi0Hh8/4dtQF40vONjJw4xEOAZmpWf81hdIf13KpQWV9GIOPbEvou+ckNGAIU0eZcGDFrfBVKffy/6ZJQ== X-Google-Smtp-Source: AGHT+IEllUiBh/ssQ0GencAPc9ZUXDdn2MKh0rz/N/KuNXYaduDio4LIz5TOboaPbdLyCpu5dsy5 X-Received: by 2002:a17:90b:4f85:b0:2a3:48a8:cf7b with SMTP id qe5-20020a17090b4f8500b002a348a8cf7bmr2362684pjb.18.1714128688020; Fri, 26 Apr 2024 03:51:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714128688; cv=pass; d=google.com; s=arc-20160816; b=gj3d3Bc7XqfkpAugfymQiaWGLrA7iLvSYdO33eBEe2gbFOaKsYanCJN5xWkjZAUp4u Y5kRa37XCE7FJpUAQP+yJNZ85N1z2xFgUOe67Bkm80wN39ACBA6mAKYxnlRnBPCN04KR ci8XdgwxkRjSdpVxcWkekQhgWCn0MZ/urMNrTRaV58G9G0EJ+OvZ1AtndD0GsnAqDapp jtfCUM+l3uHWMgOOw/Ux1gVdfJdodt/qBNf7MGhqJHtk1BK7oEuwx1GlS5oEkb4dTM6q 1N1/fSEVbtYYmjpsPT4Aud9Mw3rpNBhm5mQo87ET0ok3mcAACAF0wqGZMP0a0QQORHuv m0kA== 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=eDHNrJWkqij/SV+63DtmTcJmTu0NGlDYsoZ9xBK0dR4=; b=BfFXAZ65dQWFYze+RtM5/jzwRuEycoDFmK8VjFLvgmDWp9vqoQSB2ILi2/NO+8OsDP 516NP3gIZ/6QYEKZ3dO+HQWiXXNIGiSPOuv72348K97k9AxuNqTQJZfqI3ZBdomgF8I2 x+xl3L3tJoIJ7gVkaN0NplHP/2FsGYYWTpHv67AjKWmEWbcGik8qPOKODqdCsVO1lrKG xj0Hg5jBa1ekbLmbRPl+gXTNyuoYxpoKXRjQRhMpBBwrSzbIreiql3aAlBsIBmzPNjuU 8x3QfM8+Ap1Qo8RnDqNM1kSj2xm86ICPNhagfOjev/PLnQybvTZ7YtvI2Zi+iEATd7jO 58aw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A6KgwVKZ; 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-159901-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159901-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x12-20020a17090a6b4c00b002a509652f35si15085275pjl.131.2024.04.26.03.51.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 03:51:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159901-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A6KgwVKZ; 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-159901-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159901-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 60720284D10 for ; Fri, 26 Apr 2024 10:51:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 208D6144D3F; Fri, 26 Apr 2024 10:50:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A6KgwVKZ" 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 0F884144D1F for ; Fri, 26 Apr 2024 10:49:58 +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=1714128601; cv=none; b=BOE3b7KEpl4zD5iSy5qrMBCIGU0iej+htq1UPpVJP0XhDOV7I766zrRa0BzOvKEnl2+70nbpG1yY0XR0CaT4JN3JaatxC7Ga2SRe9nUBblz26ibKgZ8k1r+d81cIaB8oTEuPtB99MyMWGLZs+lmb4JAnL6mhuWqkU22UAdSIxSc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714128601; c=relaxed/simple; bh=FRiRwc90NawBYQ1NhQ/i4LDW0LXM9/iVyn9EgL+Kf4U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p+iKAXQgoVMxnhQiW8zORuggrrP7kW3k5aNUwpe2IeVramRrpwlzTDQyTk0PgCwmyqPQMrSzHrQLOVRFE5jrWiK+KY7Bpgej1aXTEQv4hq4XMIjMiorMCrzqWatmqN4HS4GOrFKblbQ6b7MtcLYdUSQAZnX18AAbjNPL++VIrso= 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=A6KgwVKZ; 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=1714128598; 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=A6KgwVKZcqaE3W1wk0vpl2WSFn69ohVD4WI7puqK9uq8CeAjl7Lpf0Nma045miR+E8XKag 1BnpZd70i+yeJyraRtvWv76r2nnjB44yKHkUigxmcc7IsBQjcn3EGuB2v6OaIopx81JkJt hW7P8HZmQheEeSR2UFjJY7zTA/gEB2I= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-FKVa-qTFN-WOz3nr_wbs-w-1; Fri, 26 Apr 2024 06:49:56 -0400 X-MC-Unique: FKVa-qTFN-WOz3nr_wbs-w-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-78edd30a24fso259495085a.3 for ; Fri, 26 Apr 2024 03:49:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714128596; x=1714733396; 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=D8QgKrrofjWf+IXeyCXLt76CeHKLyhZm2OBRV7BOdjdcukrj8Mm/4+oXkVnFlTG2+J TUro3dkP1DkkuLP2kpYsfs8Uxttt9QGMwnZuDxlfrUmQUZMpJePIgN9AKXVtjBu23RGa p3pFIlTwwVMJ1TpBvDLTwMI+Pa+u0zKXBa3uMz8nvJSlHQn4QOD8VnKZ6KicyFzmlelf 0lU7G6UDDiugjWfyf8k/7dmcHX4fW0KPlDWuh8//MvId3iGNvAPUQ2oRWZlTCzWAzbPl yDy3yKE2ytP9TBwy1MtpAnKmRbluAc5jTKh6St8CX6E1Zw8+tvnu5WRMG02Jbm4IVrUx NHeQ== X-Forwarded-Encrypted: i=1; AJvYcCUlTZLMdGoKpvuJ8poUkC1kXDeamnHCuV4vpCgMk5wMCxopJNxZcFY9EtS87HZyXxLUe+3+thOCipQ1Wcc8R+hHokIGCkoow1R1LSzt X-Gm-Message-State: AOJu0YxufHCSUjU9Btu5qv0RpKj2BEJj2jaG1JhuWAjZJonRBKgPJmxg 2V27ysFEB0nK3e/19iWO6dO7vtGsDvme0ImH/1bpIaYVcqYwxctfrTY63/6MITxupoYCrwRq+Ry 6LN2faGJWr8u4f/K2cnO1VOXPR1enadmSkki1vLu/vkZSKxW4fANV27s5MVygEA== X-Received: by 2002:a05:620a:558f:b0:790:9792:ccf9 with SMTP id vq15-20020a05620a558f00b007909792ccf9mr2474360qkn.26.1714128596244; Fri, 26 Apr 2024 03:49:56 -0700 (PDT) X-Received: by 2002:a05:620a:558f:b0:790:9792:ccf9 with SMTP id vq15-20020a05620a558f00b007909792ccf9mr2474347qkn.26.1714128595916; Fri, 26 Apr 2024 03:49:55 -0700 (PDT) Received: from rh.redhat.com (p200300c93f4cc600a5cdf10de606b5e2.dip0.t-ipconnect.de. [2003:c9:3f4c:c600:a5cd:f10d:e606:b5e2]) by smtp.gmail.com with ESMTPSA id vv26-20020a05620a563a00b007907b57aa1fsm3888019qkn.12.2024.04.26.03.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 03:49:55 -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 v2 1/6] KVM: arm64: change return value in arm64_check_features() Date: Fri, 26 Apr 2024 12:49:45 +0200 Message-ID: <20240426104950.7382-2-sebott@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240426104950.7382-1-sebott@redhat.com> References: <20240426104950.7382-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