Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2336869pxk; Mon, 14 Sep 2020 10:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKGwLCHb7xbcncDtGNYypbuMgHFc2BBY+c8o5KjWKLePpQzKjGDjX5gFiSoLTJWTLCgHng X-Received: by 2002:a17:906:a251:: with SMTP id bi17mr15525539ejb.526.1600104799996; Mon, 14 Sep 2020 10:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600104799; cv=none; d=google.com; s=arc-20160816; b=GS3IorDdDrp92QhpZMb2rXhsiKFZcNz7sxaw9O1zJa/j0VeLeeTFALsBsxokKlNRI7 ujyMP05BKI/dVduFfix4QrMcpMGGejsoSw3eRqoe7SADFkuB6bKirCqR6xKhM8lQTGKG 28FK5nrQX185U3z9cd5DAT3ua4TK12U5Gx8GjYRadyrIgHg0z79/+TSsKzUGk97ig9Kq 47n/HxYWPGtln7BMNgPw1dMGb2/zJ/3Ls8cmtZsKbEOMeI5ZRl/fMrfoWNNfjBCxYFjW 1XCXMSdf/BygdNrQ+5fzlrX+6s5ucV+Tu/5GNW7PGe1h2wFQyCRFG0kiRAyg9pCQwpWR 8ycw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oxR4q2exhcBC90vTFTNwz9/4eynAbLxOPQRAqHe9Mw8=; b=BSckRJxcDJVbU0aJfTNqIa9FrZCYM9V2+EQ/I5KZtaHUQAPZyASKcZXezp7tEGxiUY 9JOuUqXrkbSWHtnJqPVSBuV6feJlyz869IPNHAi0BG+ngo71BnXmvk24p2G+1Sgpribj GOV44J7ZgYKui9MaHyIEzElZAvk2CxB05odMXDuLWMADe2VjyHAKqC33r4WNQyYli110 xjsJ2A8nq4z1DBpeQp0xVm0RQUk7Ga9Etmv3N0YqDzlWJtLOn+SYXWsQz5NQtWAeu57W qZ6hRdFG1HuAdRndeKiEEUlv5v670o57EZI2XDeCk37q8gWwCeKdTqyXOtG3X5VXidYi w/yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iEFv1oxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gr23si5408833ejb.586.2020.09.14.10.32.57; Mon, 14 Sep 2020 10:33:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iEFv1oxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726342AbgINRaQ (ORCPT + 99 others); Mon, 14 Sep 2020 13:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgINR2i (ORCPT ); Mon, 14 Sep 2020 13:28:38 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3555C06178B for ; Mon, 14 Sep 2020 10:28:22 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id e17so828668wme.0 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=jNrEKdBmmNoMaGXlfxOkjDsTlOffERib6Yx4DtCIkowijOzLrdaDbRWNFlfkRiRQxU 3WDApTzO4VdS38aPI/Ah7km9+igE/Qi8TGJM948LjufzRBTkqaHHxPnZLiPCHed26ieG UXth+qunz+S9cYPj7isbzDCgjw4Xqrz7nSivnvs6xkxHVNftf/ZMkZeOFLBIQOvRveLy 52nImRTtwmYILeMEllCTBdF4I36tNYGB+QUodTfTBzOLbeB95FNRibw2QpiHkZMnZNWb 7PoUrVuXNZcqWngXsu1w6OZOoJQ3VIwW3h57Ihmb6F9fPEaWMFhUOcbBA7d4hq0K+SAv GBrA== X-Gm-Message-State: AOAM532jSDi1FZGOxOytShLYzceJvFzu5r6QGXMfRPh6H+zSz9lH2od4 mHx+niRtLr1EGDAw+CsBuEGAKg== 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 Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, natechancellor@gmail.com, ndesaulniers@google.com, dbrazdil@google.com, broonie@kernel.org, maskray@google.com, ascull@google.com, keescook@chromium.org, akpm@linux-foundation.org, dvyukov@google.com, elver@google.com, tglx@linutronix.de, arnd@arndb.de, George Popescu 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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