From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4D9633C194 for ; Wed, 26 Nov 2025 17:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764177250; cv=none; b=ogUIls0mrjQuJhbrVCusTRH/fvizQ8++Nr0ZCUq1DpK/YllHrj2AI+i+4Ap3XQOaYuYrTklcV3wDpCIduqTi6P4Rs/JU9pLY3/yMq8sivVyvJjhhmZzQvpH3EfWFXkyZ5wPtovX94z+soSQZiwlFWBmVUC32je1sX9Ib2Nc4WVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764177250; c=relaxed/simple; bh=3Ejxx6pAoM1ChRfzDminYzCeEx52+t9tKpy08nqT/aQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BObCk90AU6NFhBAbwwNDYbJvzOLEy00X1aHXJS2XcfjzxjDIwNwOssawIrvj4HFLv/eJsr5Xk1z64CIhXYI4sM3o1TND2tjiM6alt2HS6J7YU1BmI7uRb25X9kTaJpN6rUUH8ggBZDMunBqJpXeTXspD+AprtpvrWotmnEx6BRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WwifJlrr; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WwifJlrr" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-477a219db05so41887725e9.2 for ; Wed, 26 Nov 2025 09:14:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764177247; x=1764782047; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=EKxxWS88sRLsch0GDN5eUzk0Z8XTysZ7hNh3XkKXTY0=; b=WwifJlrrthmN37TlCsSaXDi+P43eVdqFDdOR5fVPJGfMVvRjgkYPvkkzGX9rDcErG7 c/a8DLrD6hSEDNdc9qqLMp5qUh3rCI6LqJjsFcw1T2wJeStF2eK9TgvetxfH8tlSqTDx rdNA7LV/rfAKTKKEDIrcSj2O3Dn0+2d/v5TM6HzeSTS9PJPMjq3BkWxrJC418y3usmdd 2PCVYF6egY0JmWZGmGNoXvsVxlxBuAZ0AYRP9CY8UVXRJnJDE9n7CM3a1pYXkxUay5OR e/pe+2laecGIPQBa9kvK/9zFAT/lIKJCRxVeAiFoofUHB3yt/0MmXxLvklc5tCjKYUNR nU3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764177247; x=1764782047; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EKxxWS88sRLsch0GDN5eUzk0Z8XTysZ7hNh3XkKXTY0=; b=YGAD3lF16WUCOJ6fKK5pr7OXhysNmGgj3Pa+lprbnihYQPiKWMlXlyaRPnfg7kn254 EzEVgIgKQcm5fa0feql6BNV9BY3ZMw1knZ7vEmQnlZbziWrXzYy5r9ueA+1KG5H5UE30 F+RvKg8L+1egHwAnmc8bPHi0A1yaGh+95ocjAvTih95dR5qDURHfX1FPyIW+S5OOalMI ApQv0X+czQLEMh3TH4d8ZNfaxoMie6+GTBi0UypzoWB816OLPHyxjg7rBJv/6Afgq4rb zFoIIOtHtoKPhKs95+BcZKr2SsX0VukEXy+buKefjUuYH3m7aW1xokROeGSJlefUQeKz hJgw== X-Forwarded-Encrypted: i=1; AJvYcCW+OUNQMvQ6zT08pOUd/EyBTPtRSy6zGdyFTJEh81vwnMnX9O38LUdbBSJYtDLzfFeHV3GzoJ+NPwJ7vII=@vger.kernel.org X-Gm-Message-State: AOJu0YwiLADS9gbvc2cSsnzAzvfw6xNHzdaDnqmRdpTitGL/re8AIK5t eFPOBz9+xDaV05JQbLBiC4K5OCbveAF4aoV5X0WABbuRjJVbg5ipIac2 X-Gm-Gg: ASbGncvhaScnZBQuauA21d96a80634cslKYXflnjFz+1zWQNoyJVbGTvyl2epZflEeD uRBwtVhRuX1lkXiYHJBklCAqP6Gbh4z0Yq5/h1WVUlDnjPGwi0PSgSwhrSaFCXJBCqDSEkm8gml ix0LYjQE1ggoUyoSs50Nz+UngGFa0vareQPYI6i+XDIZjmkq20PdxAzjI8Rlr160H7F0ow/H8r/ YBqJbXGp1gYUKsqgE09tpxLRSMyXJcfgcdg4TZk9QcGU90VSPFObJYSLU7mXNj/8w+ztXPzWkV7 nvmJfWwZDuwmLfsvIO/w7pQM11VREyhsmbvRjfOuHOMVAtgH8O/kreneBUM5XfsT5zo+SWU7uSC pBoX0j88k3Ff2rTTnw/q2SQtu8MSmfgchfH3sn2xTjK0/pcr8DP0vbfj6+i2sKEPvLrf4ej4gye qVtfw9Ca2GGt11dkpFlMF98A2goSRFGTltgA== X-Google-Smtp-Source: AGHT+IEeUlabJkkeU4URSCYq6YEVT7i8LLPu8eSrASZVzCkAxvaNf+MzxONBZP4ebaKs4/OMcLwVpg== X-Received: by 2002:a05:600c:1d1b:b0:477:9671:3a42 with SMTP id 5b1f17b1804b1-477c1133e4bmr203373495e9.35.1764177246757; Wed, 26 Nov 2025 09:14:06 -0800 (PST) Received: from [10.24.66.241] ([15.248.2.233]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42cb7f34ffesm42577404f8f.10.2025.11.26.09.14.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Nov 2025 09:14:06 -0800 (PST) Message-ID: <5cffcb56-26f7-4dac-a0ae-44329084d27d@gmail.com> Date: Wed, 26 Nov 2025 17:14:05 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/3] KVM: arm64: Add pre_fault_memory implementation To: Marc Zyngier Cc: oliver.upton@linux.dev, pbonzini@redhat.com, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, isaku.yamahata@intel.com, xmarcalx@amazon.co.uk, kalyazin@amazon.co.uk, jackabt@amazon.com References: <20251119154910.97716-1-jackabt.amazon@gmail.com> <20251119154910.97716-2-jackabt.amazon@gmail.com> <86see3r7e9.wl-maz@kernel.org> <86pl97r3ox.wl-maz@kernel.org> Content-Language: en-US From: "Thomson, Jack" In-Reply-To: <86pl97r3ox.wl-maz@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 24/11/2025 12:54 pm, Marc Zyngier wrote: > On Mon, 24 Nov 2025 11:34:38 +0000, > Marc Zyngier wrote: >> >> On Wed, 19 Nov 2025 15:49:08 +0000, >> Jack Thomson wrote: >>> > > [...] > >>> + fault_info->hpfar_el2 = HPFAR_EL2_NS | >>> + FIELD_PREP(HPFAR_EL2_FIPA, ipa >> 12); >>> + >>> + if (kvm_slot_has_gmem(memslot)) { >>> + ret = gmem_abort(vcpu, ipa, NULL, memslot, false); >>> + } else { >>> + hva = gfn_to_hva_memslot_prot(memslot, gfn, NULL); >>> + if (kvm_is_error_hva(hva)) { >>> + ret = -EFAULT; >>> + goto out; >>> + } >>> + ret = user_mem_abort(vcpu, ipa, NULL, memslot, &page_size, hva, >>> + false); >>> + } > > And thinking of it a bit more, this is completely broken. What happens > if the vcpu is in a nested context? You just populate random pages in > an IPA space that is not relevant at all, corrupting the guest state. > > You must correctly handle the context the vcpu is in, instead of > assuming that this is the canonical context. This means going via the > *guest's* S2 translation, just like handle_mem_abort() does. > > M. > Thanks Marc for taking a look, I'll update to fix these issues and address the other comments. -- Thanks, Jack