Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp645321lqp; Fri, 5 Apr 2024 05:02:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1sQloPBz/mqlpA0Vx0Qa5TqD0wgDilgPuP6R3rA+7OQK3tGw4pvhp65ZhEfCNlk5lk2Ht1/yn6Pig44NK2Ptqlf43IoIzzmuaLs/GYQ== X-Google-Smtp-Source: AGHT+IG8cQjxsmlZic2snT11zYA4+pTm9JDCC+xanCF6GH179fOR0pPcHxMjqt3ZXEnn05p0ehbv X-Received: by 2002:ac2:545b:0:b0:516:c3e1:15c5 with SMTP id d27-20020ac2545b000000b00516c3e115c5mr845200lfn.69.1712318537823; Fri, 05 Apr 2024 05:02:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712318537; cv=pass; d=google.com; s=arc-20160816; b=hmoiK1dWTMmOOSQTgR4JrhImITuenDH+1caDwJPAMMgO6p2WL0gnsYQCmyKYOG+ZtA IRd6ljMmEMMQP+5CLHjznuqVFZACBGe/HO+oQlN0NUFoJxoL8C6yKkKSNR0i9RbtMBXR vBzSfor2uc5IIpWeZxzNCmQpXqFdGzeoOmiPnd+hFl0dCYvFtSRSmhgSRS5SXm7gWf97 d7YiTWgcnWixqXDXIqNeGjhjmvAbWX5a5LcTNbsck7WpRleubMN7dq1aEzZapDs3E1yJ QzDv36iUj1VQTlXqo2B8NhUBVe8t57pj3dTo6Ge7yHTEYOtJQSnM7gmz5SGuTeOgHOHI lF7g== 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=rn4BMv+SOP2Xe0y3A99nPyLC4GfuU+9ShaoCAlDA424=; fh=YV7oH8qk281yPq6n//PP5+RU4bLLkUg2gkFwpWRa7wM=; b=q0XbsjrkClxP+2HhVQaeI22CWdwXf+UG6KIoCertyBIzBiuIfwicotx8ajBzMo2XCM LLfjHB9gcXRs0Uu1/iXW2SI8ZRYVQHfAcm3ka6Bl9ZDdBMUL7fRdZrfpc4Y4jCzoiS+A d338vCnTkLFlh/ooIfe+4rWYrT07yaolKot3cXoqorIpQto0ElTwTKAbQaOFxtCRt76u GBpxkCI+jDOyCJ3IGNHUZ32exQvFuKquMK9vYP1Ktr84TdmSv8GFX0ZL43CSRCfdm7By Jny6pY/kmo+Z8LFqudYNvk7QfMG5jeU3+lB5UoQOYV0bOlzGIdwjEywX/qP+KGW8LEn6 Gmqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iY4oCGn9; 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-132944-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132944-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y12-20020a17090668cc00b00a4e54291cbdsi643476ejr.644.2024.04.05.05.02.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:02:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132944-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iY4oCGn9; 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-132944-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132944-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 am.mirrors.kernel.org (Postfix) with ESMTPS id BDC251F22A49 for ; Fri, 5 Apr 2024 12:02:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7282316C6A5; Fri, 5 Apr 2024 12:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iY4oCGn9" 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 274BB16C859 for ; Fri, 5 Apr 2024 12:01:29 +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=1712318490; cv=none; b=t5aggCMBkpYZwwzyFqXD9hmrEnB/TJhXYZyRB+aDqHqNm670Gew9BS3j1+iO8MQTo/ZmkqMwPo4DslbyyfWNpUNMnUQmYA/xQ5Dnqf2eLPDYeZJPzDzZ3IbpapjbhFXKlN7oPPNDdHjn9urMcofap8EsiPdqaY82ca9j4eqaOVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712318490; c=relaxed/simple; bh=4UJ5Fg3bfU8lfARbEPZ8K38xQekfzxdrdG5SQuwKNMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vx66MJr5TQqBahZm2KeMvff0FGqD3pEFWaUJCFii5ngeUQPio6m2VGq6Qz9gHeCJkf+OR6Zq73GUCc/ZjeMFXgpxomqDzs7gOqtAofFlMWR0hwDldrIV0AOiPSFelDpsCYA+EIeNW2EfPeXiRAVmx+0RdinjyQwAo7o9u86pRdA= 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=iY4oCGn9; 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=1712318488; 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=rn4BMv+SOP2Xe0y3A99nPyLC4GfuU+9ShaoCAlDA424=; b=iY4oCGn9iN5w93qROm+Vs/KKt+uWq3xQF/9mIUmr5YwmLxSsnnWQvU0SyeiG6myqdMFuBQ SIulIKyge5X/NWxFSKrXZ37Q60gNOQYOdK/onczzMSq+UCA0/j1J5pfRxUV49ww7/bI2+L Tv81/m+M+3V5AtgrtQ0UuC3kbqiA9d4= 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-388-8GhajZp8PhiTcLdHUxvujw-1; Fri, 05 Apr 2024 08:01:27 -0400 X-MC-Unique: 8GhajZp8PhiTcLdHUxvujw-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-4311b01a1ecso21591371cf.2 for ; Fri, 05 Apr 2024 05:01:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712318486; x=1712923286; 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=rn4BMv+SOP2Xe0y3A99nPyLC4GfuU+9ShaoCAlDA424=; b=vO4W3/Gv2pM6S3Djd0NSYysz30ke/JN3tR9IitFB3uzOVp659JnHCOUhONHPPYqTb5 iAZZGFH2jU0Pj7zRLnv4nsx4ommbIu9Qwglh58J8c7jSGDw3vDQ7/J137U8nb5NiWzia /JGSDteyQVbKyUrUXvvdTkXDxREt4BnhPa0a/XxiH997VbaR5lLE8rXZ34WKlGZi54Ia ItVyUEE3MQkfL58DjnuIDzltiYar0eHe2lMw+FKM6A8OzmYTkI3EnFH+gU7reiy76aar XHfriR33sHsYBrVPKXW5w8rqSQqCh0MdpFbbXwGA2CnDxDhPdvCUfR6rx4lnjqGQ+xZU znWw== X-Forwarded-Encrypted: i=1; AJvYcCUkinh95pibZw/tgZvap29FBZzj7cwRrDqxMAwlx8ndIpu8PXcQN82NV6BN3Yo5nShGlQBYN4uHIMtLOnmX2cnb2f3LZn8qrhy3FXrH X-Gm-Message-State: AOJu0YzIQqaBbesjxfmggbgb2Rf3lcCrlzM3zDGcwN2lcJkpb2ckO9P3 ok15dG5LFNvIyQloVtsaDZeVIQXOFj2xDm0wJKT1rqraIzwjFcnFVIojDkCNYU99N53pmD21dvB nqANi96VJoATr8kKvafkVWaBKI5Nz3LFVDCSrL82vyj2ek+bEc82vHIigkZFRKw== X-Received: by 2002:ac8:7d0a:0:b0:431:5fad:ddbd with SMTP id g10-20020ac87d0a000000b004315fadddbdmr1508847qtb.29.1712318486527; Fri, 05 Apr 2024 05:01:26 -0700 (PDT) X-Received: by 2002:ac8:7d0a:0:b0:431:5fad:ddbd with SMTP id g10-20020ac87d0a000000b004315fadddbdmr1508823qtb.29.1712318486257; Fri, 05 Apr 2024 05:01:26 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:01:25 -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 4/4] KVM: arm64: show writable masks for feature registers Date: Fri, 5 Apr 2024 14:01:08 +0200 Message-ID: <20240405120108.11844-5-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 Instead of using ~0UL provide the actual writable mask for non-id feature registers in the output of the KVM_ARM_GET_REG_WRITABLE_MASKS ioctl. Explicitely set the mask for CLIDR_EL1 to make sure we present the same value to userspace than before. This changes the mask for the CTR_EL0 register in the output of the KVM_ARM_GET_REG_WRITABLE_MASKS ioctl. Signed-off-by: Sebastian Ott --- arch/arm64/kvm/sys_regs.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index b0ba292259f9..947aa9c0784f 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2505,7 +2505,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { { SYS_DESC(SYS_CCSIDR_EL1), access_ccsidr }, { SYS_DESC(SYS_CLIDR_EL1), access_clidr, reset_clidr, CLIDR_EL1, - .set_user = set_clidr }, + .set_user = set_clidr, .val = ~0UL }, { SYS_DESC(SYS_CCSIDR2_EL1), undef_access }, { SYS_DESC(SYS_SMIDR_EL1), undef_access }, { SYS_DESC(SYS_CSSELR_EL1), access_csselr, reset_unknown, CSSELR_EL1 }, @@ -4059,20 +4059,11 @@ int kvm_vm_ioctl_get_reg_writable_masks(struct kvm *kvm, struct reg_mask_range * if (!is_feature_id_reg(encoding) || !reg->set_user) continue; - /* - * For ID registers, we return the writable mask. Other feature - * registers return a full 64bit mask. That's not necessary - * compliant with a given revision of the architecture, but the - * RES0/RES1 definitions allow us to do that. - */ - if (is_id_reg(encoding)) { - if (!reg->val || - (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) - continue; - val = reg->val; - } else { - val = ~0UL; + if (!reg->val || + (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) { + continue; } + val = reg->val; if (put_user(val, (masks + KVM_ARM_FEATURE_ID_RANGE_INDEX(encoding)))) return -EFAULT; -- 2.42.0