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 5C1BCCED247 for ; Mon, 7 Oct 2024 23:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AfJmONIqkrrRodARYVzXrl8zpLHbhe4TWvVFD3MTZqg=; b=007CEf/9rKfGZakfqkfDyk5R/8 BMN3hKfZFkL6hj5UrfNS7yqEUOOJEtDDgs5FXkhXG1boeTadNW0G2h/LJdmfBA+alWIHw4LhvsB18 kJxugtj7bxETNzcxctI7JPnL5dxk0iFklZuAF6OD42zU1DMesK3zNOp4gTFnXWK48OkurGcJAhLDP K29YnP6eFxIvfGybijWqpzhR5HHAvn9W16fx6B/l4ScswrjTeW9HKPkVDbAxlEYyl0xLHzI7BFkB5 bNgADjsvbB76o7ELb6CEG63Tbb9mlam04v4siBkUsBucVwnrTH4rVNxi5GRnhSvUKDgtW3aUZL9Gj bZhO0Zxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxwrY-00000003yYC-2hJH; Mon, 07 Oct 2024 23:10:00 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxwqF-00000003yR4-0mDe for linux-arm-kernel@lists.infradead.org; Mon, 07 Oct 2024 23:08:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728342516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AfJmONIqkrrRodARYVzXrl8zpLHbhe4TWvVFD3MTZqg=; b=MlHAbrke7mCTU2NCdYoczvjZA+77B2NETIh182hjX/5YEaYTl+YdjGdoOZPNXUz6maBdOI fMIaQ9lVr/MyeTWgWIR8JJqFqhCI0nItHZFe85MeKAgdfmxQWKEuL1LPH7sGp4WcHASlip kB+6oR2GSI+IoQKLXzDTtIpVCEepdpY= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-UMzaSUX8Pg2dvyiyeydZHA-1; Mon, 07 Oct 2024 19:08:33 -0400 X-MC-Unique: UMzaSUX8Pg2dvyiyeydZHA-1 Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-206f9b1bc52so40832665ad.0 for ; Mon, 07 Oct 2024 16:08:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728342509; x=1728947309; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AfJmONIqkrrRodARYVzXrl8zpLHbhe4TWvVFD3MTZqg=; b=npsOY9Qq8sNRMRpppYuU0BAy6+PZZVPE0OvTg7+KSe39vleIZ3vA7OGAlE4dfIyPhf K9VURloDGMI7/X9/K2UWdh0E15NCJP2UQAXI9hEaauxHfh7O2tVadL9HHp3AULFvt0xA h37T4WNsI/rMW34ECQeu3t9QVDiuV34SoCQYsYhLitncs6VQuy/7QWLdz2cLflX+spNM 5gE9NuuUgBzacRvHTzJYXqdYcJhn9MjfG8vUsl90HT2SJxb82N3qnkCYovxeSHAkbR64 hIzT6AX3vSqSRInMf/Phy/33yo4I5ACHG7k8gFCZ6HYqfLFM2FR8YrFzhXwo4BJvCGDV /SKg== X-Forwarded-Encrypted: i=1; AJvYcCW9EJmp+Cp4bUamwu92vSFAgdWk6yX9jUc6s7s8bQY5cEWNZCKUfr1XneV/cu2TBxlJVW80QSRyx9bBJ81/4J+3@lists.infradead.org X-Gm-Message-State: AOJu0YwSeu/znQ5HMb7FKY1NMi+pm3x2b1oG5ngDdzoU9iyofkok8yj3 I/cgoHyBN5Ntqnyxn8X15LdmWc5zKMSkl4JD2qSsm9MyP/XTLi8VhvomxlMHCzFVuoGRSw/sYJv phLI+zy+fW2/Lq5I3X1vAKnPbuHq2nlDZEfqDrGF/eUf6oXHTUbPwcC05/6HneL3SOH7BmgKH X-Received: by 2002:a17:903:40d1:b0:205:9220:aa37 with SMTP id d9443c01a7336-20bfdfd31c5mr168800745ad.22.1728342509517; Mon, 07 Oct 2024 16:08:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxry6Ql2xA8l+3h1gl4I/L2BZcrkbVPn5b4zTTD+RDz9IJ0w2m9Xz1rJHClf446EHVSuntWw== X-Received: by 2002:a17:903:40d1:b0:205:9220:aa37 with SMTP id d9443c01a7336-20bfdfd31c5mr168800285ad.22.1728342509084; Mon, 07 Oct 2024 16:08:29 -0700 (PDT) Received: from [192.168.68.54] ([103.210.27.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1393175csm44740705ad.140.2024.10.07.16.08.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Oct 2024 16:08:28 -0700 (PDT) Message-ID: <2ed92455-b97f-40ba-b5d6-695e885be62f@redhat.com> Date: Tue, 8 Oct 2024 09:08:18 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 01/11] arm64: rsi: Add RSI definitions To: Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Gavin Shan References: <20241004144307.66199-1-steven.price@arm.com> <20241004144307.66199-2-steven.price@arm.com> From: Gavin Shan In-Reply-To: <20241004144307.66199-2-steven.price@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241007_160839_342492_030BDE4F X-CRM114-Status: GOOD ( 22.14 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/5/24 12:42 AM, Steven Price wrote: > From: Suzuki K Poulose > > The RMM (Realm Management Monitor) provides functionality that can be > accessed by a realm guest through SMC (Realm Services Interface) calls. > > The SMC definitions are based on DEN0137[1] version 1.0-rel0. > > [1] https://developer.arm.com/documentation/den0137/1-0rel0/ > > Signed-off-by: Suzuki K Poulose > Acked-by: Catalin Marinas > Reviewed-by: Gavin Shan > Signed-off-by: Steven Price > --- [...] > + > +static inline unsigned long rsi_set_addr_range_state(phys_addr_t start, > + phys_addr_t end, > + enum ripas state, > + unsigned long flags, > + phys_addr_t *top) > +{ > + struct arm_smccc_res res; > + > + arm_smccc_smc(SMC_RSI_IPA_STATE_SET, start, end, state, > + flags, 0, 0, 0, &res); > + > + if (top) > + *top = res.a1; > + > + if (res.a2 != RSI_ACCEPT) > + return -EPERM; > + > + return res.a0; > +} > + Similar to rsi_attestation_token_init(), the return value type needs to be 'long' since '-EPERM' can be returned from the function. > +/** > + * rsi_attestation_token_init - Initialise the operation to retrieve an > + * attestation token. > + * > + * @challenge: The challenge data to be used in the attestation token > + * generation. > + * @size: Size of the challenge data in bytes. > + * > + * Initialises the attestation token generation and returns an upper bound > + * on the attestation token size that can be used to allocate an adequate > + * buffer. The caller is expected to subsequently call > + * rsi_attestation_token_continue() to retrieve the attestation token data on > + * the same CPU. > + * > + * Returns: > + * On success, returns the upper limit of the attestation report size. > + * Otherwise, -EINVAL > + */ > +static inline long > +rsi_attestation_token_init(const u8 *challenge, unsigned long size) > +{ > + struct arm_smccc_1_2_regs regs = { 0 }; > + > + /* The challenge must be at least 32bytes and at most 64bytes */ > + if (!challenge || size < 32 || size > 64) > + return -EINVAL; > + > + regs.a0 = SMC_RSI_ATTESTATION_TOKEN_INIT; > + memcpy(®s.a1, challenge, size); > + arm_smccc_1_2_smc(®s, ®s); > + > + if (regs.a0 == RSI_SUCCESS) > + return regs.a1; > + > + return -EINVAL; > +} > + > +/** > + * rsi_attestation_token_continue - Continue the operation to retrieve an > + * attestation token. > + * > + * @granule: {I}PA of the Granule to which the token will be written. > + * @offset: Offset within Granule to start of buffer in bytes. > + * @size: The size of the buffer. > + * @len: The number of bytes written to the buffer. > + * > + * Retrieves up to a RSI_GRANULE_SIZE worth of token data per call. The caller > + * is expected to call rsi_attestation_token_init() before calling this > + * function to retrieve the attestation token. > + * > + * Return: > + * * %RSI_SUCCESS - Attestation token retrieved successfully. > + * * %RSI_INCOMPLETE - Token generation is not complete. > + * * %RSI_ERROR_INPUT - A parameter was not valid. > + * * %RSI_ERROR_STATE - Attestation not in progress. > + */ > +static inline int rsi_attestation_token_continue(phys_addr_t granule, > + unsigned long offset, > + unsigned long size, > + unsigned long *len) > +{ > + struct arm_smccc_res res; > + > + arm_smccc_1_1_invoke(SMC_RSI_ATTESTATION_TOKEN_CONTINUE, > + granule, offset, size, 0, &res); > + > + if (len) > + *len = res.a1; > + return res.a0; > +} > + The return value type of this function needs to be 'unsigned long' even it's converted to 'int' in arm_cca_attestation_continue(). In this way, the wrapper functions has consistent return value type, which is 'unsigned long' or 'long'. Thanks, Gavin