Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1814858lqz; Mon, 1 Apr 2024 19:59:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGHpamEMW7Q6ifkmPx9UjSSoLHglYE6sVj/rH/gs9Ts6bqTBJkQ1lNWRqHkcBWYnK+FVZmxsmNPJfUvlqNh1hUX/TNIsOYeWKVJVSFwg== X-Google-Smtp-Source: AGHT+IHE6xGYCO6SWskTfuV4QqlMB0Bz7K1m365DYhGtS6gNHDzF7z9JjQSukA/P5GwDGWETPAon X-Received: by 2002:a9d:4801:0:b0:6e5:22d6:5197 with SMTP id c1-20020a9d4801000000b006e522d65197mr12523944otf.23.1712026746555; Mon, 01 Apr 2024 19:59:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712026746; cv=pass; d=google.com; s=arc-20160816; b=x5BSX1K6Uo0/5/Oxyl8m4sVoQzljaO0yG4K4+cxOp6YurTMYzPYpGWTITpDatjlDso JUpmxMYQJDrH2SMUhIcSlvYCsjN7G5O8j+Xg1pHzBqKhblohf/nfvKhnIZ+DInPHfBJB casHctSM38YFbZPZZtxiiSPSyRVr+c8f37u/a7FsASxvPbjKPqt5xTQAXj9XHqufwnMH lN8xvYxutIQc3AeeXap4ScjIi0nzYw9XbcRxQTTwGeP/d9Zcnry/oj8g3HroAZuoF14k Z42hQlIKPTqRKI50QYLxZgcR6/nchcfaG9hmcsw4rKQ2m+7LSdfWw2QVh+AMGjQmk72c zpKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=pgp9minwCblRx8mvdBtDYGOXpi8+VEAGlB9hA1LNtuQ=; fh=S2E7/6r6AYDazVAR7hcOSIu9hV7qcCZRMviHUXgGzuA=; b=wl+3dEblSM7Nfhu8WFdFxNxGcs1AMVKImjy5v/DSlS0qwDFi396DdR/oZ7RYY6GJj+ JQDvmcCcAN2kpFRLpxm9Y99U5uFeZOa8DFiK4XM9gqy9s2SPbu9FH75ybwJ2ukm67xMB TBknswD7J74H250C7XwsEuvbrWXVnn42iMCQtKtV1YuH13tO7FcQgTUhli2UbRvidU+n L6ChdinnMKciFQOA2EAoOQRmMXl/1AI9zkiuWRXLgJAraeUPwfPrR3GAX4u1zt0KRKlB XBFoUk2F2I2UQ8M+g5IVN6inENRdEx+bTwRXjbhN95AvYiOhjxIL1Xs1/A3oXLayAwQb X/Fw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=lLlPDxOM; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-127319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p18-20020a63f452000000b005e42b580aadsi10245635pgk.393.2024.04.01.19.59.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 19:59:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=lLlPDxOM; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-127319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D0877B24A16 for ; Tue, 2 Apr 2024 02:50:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14D6814267; Tue, 2 Apr 2024 02:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="lLlPDxOM" Received: from xry111.site (xry111.site [89.208.246.23]) (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 D814B1118D; Tue, 2 Apr 2024 02:50:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.208.246.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712026204; cv=none; b=nRR2AGkzKWW4J+JbsjXdpJrJvdgIiKmAwOVidEOzi7xdhL5WCrMuIKP6/v2UkwKwBEeDNTabrHF3vvGa0xXyUGYibQ4WLtYwUrYs+PqIzWt0CyXnYRt/keFEk+9KzS7MZcajJMyZq/2tmXmyuExQ7yie/v87F1zpsZi7teEuhF8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712026204; c=relaxed/simple; bh=ZejHzgaX0y9u6TAm0+5L3D9OCdZlYx5y2FcAPrC4nok=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=P2FIH5J4EBBgFj1bB70vpg2iPqaQQn6gRmjjOZtAWIsla4Qy80xl3DBAbGGVN1Y/vsI9KYzyGvKxKjHjZe59TwFSe/G07HFpLxtJ2Ii4zahti6XFRZHsUKgxB4lpy5N2oU2U7rias2EaX2MPvhzfEX9rF6ar6pxVkm9KrAO6Uno= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site; spf=pass smtp.mailfrom=xry111.site; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b=lLlPDxOM; arc=none smtp.client-ip=89.208.246.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1712026200; bh=ZejHzgaX0y9u6TAm0+5L3D9OCdZlYx5y2FcAPrC4nok=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=lLlPDxOMOC6VQRM1fE3em7ahxkIummKiqw+wGHNL3WufO7u5Q9LulnvhdZAUxCmXG IROYSwo5hQ8ir8nKtBWBrZYC0VJgi3YoYQ+QK804ty1uiyveGVNjvPbDwMTy68pZ+m algdOPnQ62WvPLLIW6ID9YBdSsstgZ1WbpfcLuD4= Received: from [127.0.0.1] (unknown [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 8B63666E6D; Mon, 1 Apr 2024 22:49:57 -0400 (EDT) Message-ID: Subject: Re: [PATCH v7 3/7] LoongArch: KVM: Add cpucfg area for kvm hypervisor From: Xi Ruoyao To: maobibo , WANG Xuerui , Huacai Chen , Tianrui Zhao , Juergen Gross , Paolo Bonzini , Jonathan Corbet Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org Date: Tue, 02 Apr 2024 10:49:55 +0800 In-Reply-To: <57e66ff5-1cb6-06bd-ee6f-a3c3dadd6aef@loongson.cn> References: <20240315080710.2812974-1-maobibo@loongson.cn> <20240315080710.2812974-4-maobibo@loongson.cn> <4668e606-a7b5-49b7-a68d-1c2af86f7d76@xen0n.name> <57e66ff5-1cb6-06bd-ee6f-a3c3dadd6aef@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2024-04-02 at 09:43 +0800, maobibo wrote: > > Sorry for the late reply, but I think it may be a bit non-constructive= =20 > > to repeatedly submit the same code without due explanation in our=20 > > previous review threads. Let me try to recollect some of the details > > though... > Because your review comments about hypercall method is wrong, I need not= =20 > adopt it. Again it's unfair to say so considering the lack of LVZ documentation. /* snip */ >=20 > 1. T0-T7 are scratch registers during SYSCALL ABI, this is what you=20 > suggest, does there exist information leaking to user space from T0-T7 > registers? It's not a problem. When syscall returns RESTORE_ALL_AND_RET is invoked despite T0-T7 are not saved. So a "junk" value will be read from the leading PT_SIZE bytes of the kernel stack for this thread. The leading PT_SIZE bytes of the kernel stack is dedicated for storing the struct pt_regs representing the reg file of the thread in the userspace. Thus we may only read out the userspace T0-T7 value stored when the same thread was interrupted or trapped last time, or 0 (if the thread was never interrupted or trapped before). And it's impossible to read some data used by the kernel internally, or some data of another thread. But indeed there is some improvement here. Zeroing these registers seems cleaner than reading out the junk values, and also faster (move $t0, $r0 is faster than ld.d $t0, $sp, PT_R12). Not sure if it's worthy to violate Huacai's "keep things simple" aspiration though. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University