From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 038A9CD1296 for ; Wed, 10 Apr 2024 09:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q7+BvDBN3LARZSHsRl3BeGYWSUJA0ilCcLbMnNXJmhI=; b=PXz77kS0H8FKMh v68KAbhDnbgoHN+BQoAH8AihMw/3n4mCdhijl2chzbfmDxamTfDALslPH7CnkKah4YCvqaHwPQZBC LQ+uj7axVfgYufwJ5Ie/t53jr9IY/LL2yrtvBreYQC4BBw9YJqXEMRsV/6sv6VuPC1Olcx6gj7n5J 9CqhggFPcw67OfloJ8EYF9io+cN3WbVZIBPwjdyT/8pNE9g9EOxJgQWW8W33T6rj7I3gv7AA48tdx 5uhYlh9JwI2vPdWmMwDDfwDezUUbTQpk4gpiH4f8XuKTogMsozyjXgUKnmbrMTrQgSqDyIeEiapf5 CKMnZTI5vweY5A2oafVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruUeC-00000006FHP-0XD6; Wed, 10 Apr 2024 09:53:40 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruUe9-00000006FFi-2dZe for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2024 09:53:39 +0000 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d47a92cfefso82406721fa.1 for ; Wed, 10 Apr 2024 02:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712742815; x=1713347615; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=a5V6Ab5KYZlb0KtyTlJwyIxL2QcpWe2gp9lR05o6q98=; b=eb2X8ZvB/EcDr2Umw8G1EULUFP9dNv68wQpNz2RvUARv0I66L6ceLv+Frc6K0ow+AO 7LQBYmSafqUMYb/yu48zJ2Iqv7qIYobDWBBdvyo/WbOPi7Pj2/t6dNSDKaZe87HgzkNZ 1bhA8zA9Xwdtp0mW86CgMLcbY2yB5ZVh+bmyx6bfwkjAXgeymThfGUeH+qGLpu+G0zdi bOPtqdhssNxFETFcTIxMRWvnKSHmOkC7nGgw8wkFmccmIHXfBpVMwONJK/dpVRJUfedj iTGQ3TBqf0sc5anDANDuoNA+D3iJfjjITn4sD3PGFAvU4zHMHiHau7dUQd2ImcRTlNRv L2hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712742815; x=1713347615; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=a5V6Ab5KYZlb0KtyTlJwyIxL2QcpWe2gp9lR05o6q98=; b=cRBoZ8jvUNRdkjQHq1KDE3fkmaG55zinLQz3Hc4FVpX3LGtu+mDO+wz8cebkpykR0w rMh94+tZQrMhxrQW+6H3aNSBVSWo/YMw93bTcJE1Q/GnSgf52PmoT1ptlOb/ouzkAb3d v7cKVRbF2QobQbH6r0RNEjov0T+QaO/XXPf5SMW3AC6eMEbArAdozvJ6sfHQFnsIbN7Z AHNsoCkhR6YB53/dL1WgJ40wqUH/8nLlEY6Pog73VpWawxsP2b4WkKbPwQ9pGUWQirv+ HcgleYtRdw+2ryx2nuf2kVDISFaZSkwx798lS3UqPUkWdH1pYV+58jCWxtwjVpLgBeed 86vA== X-Forwarded-Encrypted: i=1; AJvYcCVPWCfqgxmrdSw46K3KvPLpH4PogEb3FPEUyWfz/361U4TOlRprQ4se77GkD6UOnyN27Qn0O1knSssyK11Ar7JV78UFdUQa5Q+a13iattTqRhMu0h4= X-Gm-Message-State: AOJu0Yx1IkeUEuUQRwBOaOjmdEek6B2Wqsly5rsvEpWZBX1YA6udPpP+ Lb5dXm6zFE4/1iycgZY44yBjyE6hhOqBZn15jq8WMP+5CE2Any8YLR3mvLH34w== X-Google-Smtp-Source: AGHT+IFI7ac6E7BZYOo32rnOqFa6a7C6UIEWBLNvFOj/PVUT5To2IkCy5/i4IwMhkFIMY9cwo/mWyA== X-Received: by 2002:a2e:a9a6:0:b0:2d8:be29:4ca9 with SMTP id x38-20020a2ea9a6000000b002d8be294ca9mr2001820ljq.39.1712742815139; Wed, 10 Apr 2024 02:53:35 -0700 (PDT) Received: from google.com (161.126.77.34.bc.googleusercontent.com. [34.77.126.161]) by smtp.gmail.com with ESMTPSA id he8-20020a05600c540800b00416a08788a5sm1757388wmb.27.2024.04.10.02.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 02:53:34 -0700 (PDT) Date: Wed, 10 Apr 2024 10:53:31 +0100 From: Vincent Donnefort To: Sebastian Ene Cc: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH] KVM: arm64: Add support for FFA_PARTITION_INFO_GET Message-ID: References: <20240409151908.541589-1-sebastianene@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_025337_713844_49820AC7 X-CRM114-Status: GOOD ( 22.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [...] > > > +static void do_ffa_part_get(struct arm_smccc_res *res, > > > + struct kvm_cpu_context *ctxt) > > > +{ > > > + DECLARE_REG(u32, uuid0, ctxt, 1); > > > + DECLARE_REG(u32, uuid1, ctxt, 2); > > > + DECLARE_REG(u32, uuid2, ctxt, 3); > > > + DECLARE_REG(u32, uuid3, ctxt, 4); > > > + DECLARE_REG(u32, flags, ctxt, 5); > > > + u32 off, count, sz, buf_sz; > > > + > > > + hyp_spin_lock(&host_buffers.lock); > > > + if (!host_buffers.rx) { > > > + ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS); > > > + goto out_unlock; > > > + } > > > + > > > + arm_smccc_1_1_smc(FFA_PARTITION_INFO_GET, uuid0, uuid1, > > > + uuid2, uuid3, flags, 0, 0, > > > + res); > > > + > > > + if (res->a0 != FFA_SUCCESS) > > > + goto out_unlock; > > > + > > > + count = res->a2; > > > + if (!count) > > > + goto out_unlock; > > > > Looking at the table 13.34, it seems what's in "count" depends on the flag. > > Shouldn't we check its value, and only memcpy into the host buffers if the flag > > is 0? > > > > When the flag is `1` the count referes to the number of partitions > deployed. In both cases we have to copy something unless count == 0. I see "Return the count of partitions deployed in the system corresponding to the specified UUID in w2" Which I believe means nothing has been copied in the buffer? > > > > + > > > + if (ffa_version > FFA_VERSION_1_0) { > > > + buf_sz = sz = res->a3; > > > + if (sz > sizeof(struct ffa_partition_info)) > > > + buf_sz = sizeof(struct ffa_partition_info); > > > > What are you trying to protect against here? We have to trust EL3 anyway, (as > > other functions do). > > > > The WARN() could be kept though to make sure we won't overflow our buffer. But > > it could be transformed into an error? FFA_RET_ABORTED? > > > > > > I think we can keep it as a WARN_ON because it is not expected to have > a return code of FFA_SUCCESS but the buffer to be overflown. The TEE is > expected to return NO_MEMORY in w2 if the results cannot fit in the RX > buffer. WARN() is crashing the hypervisor. It'd be a shame here as we can easily recover by just sending an error back to the caller. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel