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 X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BDF5C4363A for ; Mon, 26 Oct 2020 14:36:33 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id E60F520780 for ; Mon, 26 Oct 2020 14:36:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Pqj0b7NA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E60F520780 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 605EE4B45C; Mon, 26 Oct 2020 10:36:32 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5+jfHlBGfP0c; Mon, 26 Oct 2020 10:36:31 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5FF404B4C0; Mon, 26 Oct 2020 10:36:31 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id EF9D64B454 for ; Mon, 26 Oct 2020 10:36:29 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OLn59nNiZRN4 for ; Mon, 26 Oct 2020 10:36:29 -0400 (EDT) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id D856F4B43D for ; Mon, 26 Oct 2020 10:36:28 -0400 (EDT) Received: by mail-wm1-f68.google.com with SMTP id c16so12721536wmd.2 for ; Mon, 26 Oct 2020 07:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MerDsv/XmBWBzmLIOlTgREdfdkOm0MotoeVYk/L2CXA=; b=Pqj0b7NAxAQeGChbWijWaY4tsNONaAR9oWWuCz66Rw4h3OvJOXQRMudZ+Rp+j3Bo3X JncmRLLVjT6tY5sgPuZ7iWz8Bj0uvPru028mnI+pJs8h+/FqmdDCNbgCRnrlFel++ifw iOwzQyimqGCGDTwM/i5wxNwoa8GS+9T2U4WXahJW4qImsDZuVCP+BI69yLwIZb0e5TP6 DVbNdVRVVwWXmBfiPsfcNkKasuDoPIW1bsL3jUbGkGzijWc7CnBMfhG4C+FRJ4ukWyUK 5hG0llpleWM1WFGvZNHkZWqZd/2e0t93rAFOREJp1pHqaLHvNnma1EKIcplUoPHwUX9S HdLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MerDsv/XmBWBzmLIOlTgREdfdkOm0MotoeVYk/L2CXA=; b=YXj/bSL2FkBmAlFBCI6p+BhtTUav/2XVG0yj/J4RM9S3tfc/dJxbUMmTsdSXuwikyE zGGTroZ+LdYnW4Cl2LV3QMiZMJvZMg1tjow/FEcSMuBkQ7VP70gNbTTNpZL1maegFjv5 6NyMqQYIvtxgDFxwikGiI6DTna70ZKzr7r4On1gpwX0+r2X5Bh493D7xmkttjqyQbTEo 236GOsca3l8v8XDV/VTKgPoiccNtGz4lZUE7ZyNGCdbk3k79B58p6aiX0VoKJ8B2cQH1 Byfx9AUKU7koez+/z3WAlGZkIqWSy4WQASOJ44lUQBpgL9pvNPCaa0DKj36azDGiaauo 3MhA== X-Gm-Message-State: AOAM5314naXZapS0rMQAAAVhZY8AcYaNy2ln49AKO9uCTqQZSUMU/tGC GX/yRwVY/0uotEi1DGA7477MJg== X-Google-Smtp-Source: ABdhPJyeJBArajEh/qV0h65NryMws8JKnoPSvxRiqZYn8gQ8o5uMxcIaCVxiY2Ofp3J6w3GhdnhfXw== X-Received: by 2002:a7b:c0d3:: with SMTP id s19mr6858264wmh.102.1603722987718; Mon, 26 Oct 2020 07:36:27 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id c18sm20080039wmk.36.2020.10.26.07.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 07:36:27 -0700 (PDT) Date: Mon, 26 Oct 2020 14:36:23 +0000 From: Quentin Perret To: Marc Zyngier Subject: Re: [PATCH 1/8] KVM: arm64: Don't corrupt tpidr_el2 on failed HVC call Message-ID: <20201026143623.GA2229434@google.com> References: <20201026095116.72051-1-maz@kernel.org> <20201026095116.72051-2-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201026095116.72051-2-maz@kernel.org> Cc: kvm@vger.kernel.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org, Will Deacon , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Monday 26 Oct 2020 at 09:51:09 (+0000), Marc Zyngier wrote: > The hyp-init code starts by stashing a register in TPIDR_EL2 > in in order to free a register. This happens no matter if the > HVC call is legal or not. > > Although nothing wrong seems to come out of it, it feels odd > to alter the EL2 state for something that eventually returns > an error. > > Instead, use the fact that we know exactly which bits of the > __kvm_hyp_init call are non-zero to perform the check with > a series of EOR/ROR instructions, combined with a build-time > check that the value is the one we expect. Alternatively, could we make __kvm_hyp_init non-SMCCC compliant? While I understand how it makes sense to be compliant for 'proper' HVCs, this one really is an odd one that only makes sense on a very transient state. That would let us define our convention, and we can just say x0-x18 can be clobbered like any function call, which eradicates the issue Andrew tried to avoid with this tpidr_el2 trick. Thoughts? Thanks, Quentin _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A16B2C4363A for ; Mon, 26 Oct 2020 14:37:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 567C12168B for ; Mon, 26 Oct 2020 14:37:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Xoacv0bE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Pqj0b7NA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 567C12168B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=hzvG1nB7uodLJ2dQ/z1KPnhHkN9I7hn39ztzumsJPqg=; b=Xoacv0bEEhFM4Dym+su3L85QI OyMNwOagRUqemLEui0ewrui0iwf+Plu5hrpc2/QG7q8CqCDkbUKXm5ZwOVWSHJgtb3xpiO+r+uUpA 7I0U+QWmqBtq03STKAiIxAKQe+GCapxrkyLwjYnmHt0jn2tPZp5TjvaWYBlzprkXWEFLSobHMPEk+ LyOWGvRF5YgwBRVISiI0l9Pnr0axQUJY8vHRwzs8bsSCjqp6gBSmEWUw/8mwx6A0FuCZCykwB50uO cBj6ygTcppWtc2qAd/ChxPaivpHLqGfaivJeOmmr1ExXrDNbsW8kmqUWTwIm2b0rjEJFfBjlrXEdc ZhcFv1+nw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kX3bt-00019J-B8; Mon, 26 Oct 2020 14:36:33 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kX3bq-000183-HU for linux-arm-kernel@lists.infradead.org; Mon, 26 Oct 2020 14:36:31 +0000 Received: by mail-wm1-x343.google.com with SMTP id k21so5852929wmi.1 for ; Mon, 26 Oct 2020 07:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MerDsv/XmBWBzmLIOlTgREdfdkOm0MotoeVYk/L2CXA=; b=Pqj0b7NAxAQeGChbWijWaY4tsNONaAR9oWWuCz66Rw4h3OvJOXQRMudZ+Rp+j3Bo3X JncmRLLVjT6tY5sgPuZ7iWz8Bj0uvPru028mnI+pJs8h+/FqmdDCNbgCRnrlFel++ifw iOwzQyimqGCGDTwM/i5wxNwoa8GS+9T2U4WXahJW4qImsDZuVCP+BI69yLwIZb0e5TP6 DVbNdVRVVwWXmBfiPsfcNkKasuDoPIW1bsL3jUbGkGzijWc7CnBMfhG4C+FRJ4ukWyUK 5hG0llpleWM1WFGvZNHkZWqZd/2e0t93rAFOREJp1pHqaLHvNnma1EKIcplUoPHwUX9S HdLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MerDsv/XmBWBzmLIOlTgREdfdkOm0MotoeVYk/L2CXA=; b=sjExHyoDvOJqX+IqlEkWWY4lDfJSUIaf2VDJtctJiX+lVx3BL9Ajg6uEp6UuVbpD3c CJTqWmp4vPZzctRjQWbl+0luJkWCoN7sGOhvxQXZr84HHuOBUCPuVrGoemG00RKXK2iK pesaUDyvM9/Kc2QXKOALbYgO26IS25pqRgLcklYZKhu5wZaA8otTMDFHJ8wbeOZgdkot 7pGr1M7bxyQ4TV6JOvyfUsMGoycUqTKSw45LsJW2ho0CZAiDpRgq2AL5IwvngtwF2FZH 6Nfp2bPfLAgWF3UPz4/DODtLd3LFJTc6WEUJP4F3L/CBBdf1z+wAclZIDvB3d2XjPgI5 MTWQ== X-Gm-Message-State: AOAM532ce1vD74Hv3W9Qj0pyzwGUxmgIagV+KV3m4xwBQ9UMgHrvWkkh H9dOZ7UETSoGLzeSIGtwsGHBsg== X-Google-Smtp-Source: ABdhPJyeJBArajEh/qV0h65NryMws8JKnoPSvxRiqZYn8gQ8o5uMxcIaCVxiY2Ofp3J6w3GhdnhfXw== X-Received: by 2002:a7b:c0d3:: with SMTP id s19mr6858264wmh.102.1603722987718; Mon, 26 Oct 2020 07:36:27 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id c18sm20080039wmk.36.2020.10.26.07.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 07:36:27 -0700 (PDT) Date: Mon, 26 Oct 2020 14:36:23 +0000 From: Quentin Perret To: Marc Zyngier Subject: Re: [PATCH 1/8] KVM: arm64: Don't corrupt tpidr_el2 on failed HVC call Message-ID: <20201026143623.GA2229434@google.com> References: <20201026095116.72051-1-maz@kernel.org> <20201026095116.72051-2-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201026095116.72051-2-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_103630_653319_A4822AAA X-CRM114-Status: GOOD ( 15.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Suzuki K Poulose , kernel-team@android.com, James Morse , linux-arm-kernel@lists.infradead.org, Will Deacon , kvmarm@lists.cs.columbia.edu, Julien Thierry , Andrew Scull 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 On Monday 26 Oct 2020 at 09:51:09 (+0000), Marc Zyngier wrote: > The hyp-init code starts by stashing a register in TPIDR_EL2 > in in order to free a register. This happens no matter if the > HVC call is legal or not. > > Although nothing wrong seems to come out of it, it feels odd > to alter the EL2 state for something that eventually returns > an error. > > Instead, use the fact that we know exactly which bits of the > __kvm_hyp_init call are non-zero to perform the check with > a series of EOR/ROR instructions, combined with a build-time > check that the value is the one we expect. Alternatively, could we make __kvm_hyp_init non-SMCCC compliant? While I understand how it makes sense to be compliant for 'proper' HVCs, this one really is an odd one that only makes sense on a very transient state. That would let us define our convention, and we can just say x0-x18 can be clobbered like any function call, which eradicates the issue Andrew tried to avoid with this tpidr_el2 trick. Thoughts? Thanks, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0E6BC2D0A3 for ; Mon, 26 Oct 2020 14:40:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A58452168B for ; Mon, 26 Oct 2020 14:40:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Pqj0b7NA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1781710AbgJZOi2 (ORCPT ); Mon, 26 Oct 2020 10:38:28 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50509 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1780843AbgJZOg3 (ORCPT ); Mon, 26 Oct 2020 10:36:29 -0400 Received: by mail-wm1-f65.google.com with SMTP id 13so11889422wmf.0 for ; Mon, 26 Oct 2020 07:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MerDsv/XmBWBzmLIOlTgREdfdkOm0MotoeVYk/L2CXA=; b=Pqj0b7NAxAQeGChbWijWaY4tsNONaAR9oWWuCz66Rw4h3OvJOXQRMudZ+Rp+j3Bo3X JncmRLLVjT6tY5sgPuZ7iWz8Bj0uvPru028mnI+pJs8h+/FqmdDCNbgCRnrlFel++ifw iOwzQyimqGCGDTwM/i5wxNwoa8GS+9T2U4WXahJW4qImsDZuVCP+BI69yLwIZb0e5TP6 DVbNdVRVVwWXmBfiPsfcNkKasuDoPIW1bsL3jUbGkGzijWc7CnBMfhG4C+FRJ4ukWyUK 5hG0llpleWM1WFGvZNHkZWqZd/2e0t93rAFOREJp1pHqaLHvNnma1EKIcplUoPHwUX9S HdLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MerDsv/XmBWBzmLIOlTgREdfdkOm0MotoeVYk/L2CXA=; b=YWUK1AemvBlySl3pfaYSc5M8LrrnMtZpqii+35cTzWD85MiNUDWTMa8w+R2ue4RP+X yvRXT2bO2FLoOrSUTYp7w8wkLsFhec+PENmtt6KtKKSvLbsQ5VASe0xw0bn5veyNpjFS ixDFN+ggdL5RiUMti+aJDSL2CT8PBRy1WCTh/A1hHV/AN2LLHgoWdl9+FZgpMvGXyslk Q61Srl7VMn8rBNepF/M8wnUQoBV2rNObsO2+BbHs0N0mHxJ4l2E/KQGYo63Bpz+epOKe IqavbAL8JJlb9r54VZ2BxZ1TEBxnEerKdEuNhGbZt0mqdbq4drFnMHR+PTqP8JaLeDZ7 oLuA== X-Gm-Message-State: AOAM5325lsRjIScCvrsuzB6pDgkYrbUNVuz6wfpKVG3XSpqxPJXhhvWu 5M4IM9pIr8tx6oyAkTUjU6tZ4g== X-Google-Smtp-Source: ABdhPJyeJBArajEh/qV0h65NryMws8JKnoPSvxRiqZYn8gQ8o5uMxcIaCVxiY2Ofp3J6w3GhdnhfXw== X-Received: by 2002:a7b:c0d3:: with SMTP id s19mr6858264wmh.102.1603722987718; Mon, 26 Oct 2020 07:36:27 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id c18sm20080039wmk.36.2020.10.26.07.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 07:36:27 -0700 (PDT) Date: Mon, 26 Oct 2020 14:36:23 +0000 From: Quentin Perret To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , Andrew Scull , Will Deacon , kernel-team@android.com Subject: Re: [PATCH 1/8] KVM: arm64: Don't corrupt tpidr_el2 on failed HVC call Message-ID: <20201026143623.GA2229434@google.com> References: <20201026095116.72051-1-maz@kernel.org> <20201026095116.72051-2-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201026095116.72051-2-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Monday 26 Oct 2020 at 09:51:09 (+0000), Marc Zyngier wrote: > The hyp-init code starts by stashing a register in TPIDR_EL2 > in in order to free a register. This happens no matter if the > HVC call is legal or not. > > Although nothing wrong seems to come out of it, it feels odd > to alter the EL2 state for something that eventually returns > an error. > > Instead, use the fact that we know exactly which bits of the > __kvm_hyp_init call are non-zero to perform the check with > a series of EOR/ROR instructions, combined with a build-time > check that the value is the one we expect. Alternatively, could we make __kvm_hyp_init non-SMCCC compliant? While I understand how it makes sense to be compliant for 'proper' HVCs, this one really is an odd one that only makes sense on a very transient state. That would let us define our convention, and we can just say x0-x18 can be clobbered like any function call, which eradicates the issue Andrew tried to avoid with this tpidr_el2 trick. Thoughts? Thanks, Quentin