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=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 587CBC43461 for ; Mon, 14 Sep 2020 17:31:47 +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 E168020771 for ; Mon, 14 Sep 2020 17:31:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="igbvHG8j"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="iEFv1oxO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E168020771 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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8IWHy0p+gNTMIKt26r5XkyOqjCcb2q1rGBfv/FWNFbc=; b=igbvHG8jAI8Jl7l3KlkN4rr+n li4G661SBagyPiQTN2ktN8IV4RxnbN1hRNEHImrXgDSlELglsxgkuXYX7g02v5K2M6lSEK9CxPDMt sAqe0Jk0fluW7fW2yLxzyoW8B8uGoK5776nkZxRg33TBvnU/P+drMmMuqXAICaxuIrjBbNg7avCMG /OPdgq1B+LF13lMlyr9abfqfjx2ckOZl6aWLP5HaFlo5OqT3xU79uyNT/7j28w4rKPkOnpWeIG2CX QEocbtMRehkcK1Bs6asoMv6z81vhQpC4T5l0W/mXiKjnuHTcajQx7KhWmcqxeh0rkY8g+S1pBFYkr /RDBIg3IQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHsIM-0001Aj-Jq; Mon, 14 Sep 2020 17:29:38 +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 1kHsH8-0000db-IO for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 17:28:24 +0000 Received: by mail-wm1-x343.google.com with SMTP id x23so810993wmi.3 for ; Mon, 14 Sep 2020 10:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oxR4q2exhcBC90vTFTNwz9/4eynAbLxOPQRAqHe9Mw8=; b=iEFv1oxODcKOHWza+NvTccTL3/wQordMg3U1eoRfqFg8wT2ZdgAAKIR5TqyBMDSz7j p6Two6b4VjgeiaRHbB/+ioQrmadcmqQvnY2N2R59qUqGWhKvSFcPBbecWZMmsRSOU+b8 KasiVBhlOh+RhMOjN/LwusWdi6h9O0xedIEU1Db+QSOrCrPoo9U0qsW40Nrzrbp0EX3n +kIWWdPuoVXtvUJpO3w/+q3szInGmWzwUlyfDpMM1RV0gzMMrgepqVoqPV5Re2h4Id55 72djWWoXs5+9bVxRyrIlmei/6++TYwru7YoKIBE4OfzDSAe/C622EhPn8E3Mn02ok9ma srOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oxR4q2exhcBC90vTFTNwz9/4eynAbLxOPQRAqHe9Mw8=; b=f+SkckfbeFSsrh5Y9cG8+FCQGhES+0NxUYpmlYteTmutP0n6jwHVNL2d79wyfHhbSk lkUTcP4vNbmx795irlIeinTunb9JUu7Hg7Q439x/Q9RFBtxPlKEtCfLckSxqM4H4uxNu yVs7ZQppEHE9DGSqHqEyJWPQ9LZKYgAC5iMaeF6v4jhss1Jw9KEJDvxD3NRszwRzdatE 9ABv25dAzxQy2ydVGsF1ie4tLhS7tukRCVKj1PHNmhz3eN965PwW3WgC0/fjt36hSrZo AJUEitqgbeN0rmGRjZ1LFP2C0gaG506AvgUoXU5oKkRUzDO7hHda09YrRzYph7HRd5Ro qjyg== X-Gm-Message-State: AOAM533ib0BmbAsxB2ES/1wlU0JnSgwrn4RxwYe46hGnqtOhTtnV8mV9 eKe/6eNyCePPoTy5kBzMXQ2Vlw== X-Google-Smtp-Source: ABdhPJziHq0hb99caNbhZ6ZpDc46fHJPvgXN25hJZzyvPSDfDyF5i1/XYuIsmSM1xvZxBc9ptSKANw== X-Received: by 2002:a1c:6145:: with SMTP id v66mr426746wmb.171.1600104501282; Mon, 14 Sep 2020 10:28:21 -0700 (PDT) Received: from localhost (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id m1sm20204287wmc.28.2020.09.14.10.28.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 10:28:20 -0700 (PDT) From: George-Aurelian Popescu To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, masahiroy@kernel.org, michal.lkml@markovi.net Subject: [PATCH 10/14] KVM: arm64: __ubsan_handle_load_invalid_value hyp/nVHE implementation. Date: Mon, 14 Sep 2020 17:27:46 +0000 Message-Id: <20200914172750.852684-11-georgepope@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200914172750.852684-1-georgepope@google.com> References: <20200914172750.852684-1-georgepope@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_132822_721953_78BBE027 X-CRM114-Status: GOOD ( 15.68 ) 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: arnd@arndb.de, elver@google.com, tglx@linutronix.de, keescook@chromium.org, maskray@google.com, linux-kbuild@vger.kernel.org, suzuki.poulose@arm.com, ndesaulniers@google.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, George Popescu , clang-built-linux@googlegroups.com, broonie@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, dvyukov@google.com, natechancellor@gmail.com, dbrazdil@google.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, ascull@google.com 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 From: George Popescu The handler for the load invalid value undefined behaviour is implemented for hyp/nVHE. The handler's parameters are stored inside the buffer. They are used by the symmetric handler from the kernel. Signed-off-by: George Popescu --- arch/arm64/include/asm/kvm_ubsan.h | 5 ++++- arch/arm64/kvm/hyp/nvhe/ubsan.c | 14 +++++++++++++- arch/arm64/kvm/kvm_ubsan_buffer.c | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_ubsan.h b/arch/arm64/include/asm/kvm_ubsan.h index 3130a80cd8b2..b643ac9a4090 100644 --- a/arch/arm64/include/asm/kvm_ubsan.h +++ b/arch/arm64/include/asm/kvm_ubsan.h @@ -22,12 +22,14 @@ struct kvm_ubsan_info { UBSAN_NONE, UBSAN_OUT_OF_BOUNDS, UBSAN_UNREACHABLE_DATA, - UBSAN_SHIFT_OUT_OF_BOUNDS + UBSAN_SHIFT_OUT_OF_BOUNDS, + UBSAN_INVALID_DATA } type; union { struct out_of_bounds_data out_of_bounds_data; struct unreachable_data unreachable_data; struct shift_out_of_bounds_data shift_out_of_bounds_data; + struct invalid_value_data invalid_value_data; }; union { struct ubsan_values u_val; @@ -38,3 +40,4 @@ struct kvm_ubsan_info { void __ubsan_handle_out_of_bounds(void *_data, void *index); void __ubsan_handle_builtin_unreachable(void *_data); void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs); +void __ubsan_handle_load_invalid_value(void *_data, void *val); diff --git a/arch/arm64/kvm/hyp/nvhe/ubsan.c b/arch/arm64/kvm/hyp/nvhe/ubsan.c index 40b82143e57f..1888a1f51724 100644 --- a/arch/arm64/kvm/hyp/nvhe/ubsan.c +++ b/arch/arm64/kvm/hyp/nvhe/ubsan.c @@ -82,4 +82,16 @@ void __ubsan_handle_builtin_unreachable(void *_data) } } -void __ubsan_handle_load_invalid_value(void *_data, void *val) {} +void __ubsan_handle_load_invalid_value(void *_data, void *val) +{ + struct kvm_ubsan_info *slot; + struct invalid_value_data *data = _data; + + slot = kvm_ubsan_buffer_next_slot(); + if (slot) { + slot->type = UBSAN_INVALID_DATA; + slot->invalid_value_data = *data; + slot->u_val.lval = val; + } + +} diff --git a/arch/arm64/kvm/kvm_ubsan_buffer.c b/arch/arm64/kvm/kvm_ubsan_buffer.c index b4a282bec91d..01bf2171af9e 100644 --- a/arch/arm64/kvm/kvm_ubsan_buffer.c +++ b/arch/arm64/kvm/kvm_ubsan_buffer.c @@ -32,6 +32,10 @@ void __kvm_check_ubsan_data(struct kvm_ubsan_info *slot) __ubsan_handle_shift_out_of_bounds(&slot->shift_out_of_bounds_data, slot->u_val.lval, slot->u_val.rval); break; + case UBSAN_INVALID_DATA: + __ubsan_handle_load_invalid_value(&slot->invalid_value_data, + slot->u_val.lval); + break; } } -- 2.28.0.618.gf4bc123cb7-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel