Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp439990pxb; Thu, 14 Jan 2021 09:27:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjKiJBzGpeXLvusR5U7JicaWtmkQYULv+np21yI5Zq7Mt+0D2/fc/526dyft50m4zvgLOU X-Received: by 2002:a50:ed17:: with SMTP id j23mr6616340eds.218.1610645257410; Thu, 14 Jan 2021 09:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610645257; cv=none; d=google.com; s=arc-20160816; b=krV5TqzAfoGwjzg5YFi4WuWzNnQHEs/7opvmwjw5advW7gpv/+aB/3/0ee9h+2qOEj YSO4BQCpLl9BE7ed5xs9WCPNE7GS+IsTnzpTFpz5osUk+YTra1Qho+cpSVPyCajBcWC+ FUcdF9mXh24CZ2wER+WPCUZABV+N6onB3hgNd1cNBSLeO9WP46U6OXYW3rS/EfIrrMjR O4zyMEfsvsyO562kmoxZYkniXQvnFAx7YSi7heN6TXHbyslMLH5ZjwKs9feymAUH7Erl FE7YFGMyur2/sYhGoFeIo2VIiiLgPMIVLJ401jjUdEyEV5Xzz/jjrhAeeavMTlSmkIqq HKZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=mBnNW8oub18hKhhe8yHqfoSEZU2iRCB395w7gjgwxWc=; b=N6jZz+iw2YzRqBVO3N7IMjeazybIg4komR0BOpAHWMbrsI05CJNSrFMVdWf2vbYb6T AOOfhwmNJbRU49J/1cUjSIM87dJpdvAQgIGNYXwm23hWKQVBN+r0V5UylAWLAuO4ZUI6 9jF1mEfG6h933Ip6YGSc56+0NwKclJOl775FyVMl6cu92sLcQubGBss92gsyZIHNImgm RXoG4ZNfzKLwRj5IUMga4VhqbbtHYwDZdZWxZ82Sc0hNZOKKbX9dRvzLiK0FthRdry8d r7iDfiYfUO+dVHhfaxGtztB6xGQV5Gabiq4tLvF2Aw3JbtR3QCNMdZwVU+1rodJEUXE2 ygCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YyThgL18; 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 e4si382176edk.306.2021.01.14.09.27.12; Thu, 14 Jan 2021 09:27:37 -0800 (PST) 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=YyThgL18; 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 S1728580AbhANRZh (ORCPT + 99 others); Thu, 14 Jan 2021 12:25:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbhANRZg (ORCPT ); Thu, 14 Jan 2021 12:25:36 -0500 Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 795C5C0613D3 for ; Thu, 14 Jan 2021 09:24:55 -0800 (PST) Received: by mail-wr1-x449.google.com with SMTP id o17so2899678wra.8 for ; Thu, 14 Jan 2021 09:24:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=mBnNW8oub18hKhhe8yHqfoSEZU2iRCB395w7gjgwxWc=; b=YyThgL189juUYY1QafUrt/nr4mL1Dlewr+4os9Exz6q+m6zwQXnoNIhxbHXPalrLo3 rT8BweykI8RXTWknugQU6KAjnTbwTL5UC5KFh1fQWQXdH41NrYXFexJt5/aptCnupsFC 0d1H6PKi/v1QEYbt0efPZVVZD5cgvjLF83q3cN7iaf2PLa7zmhtCGfTdNqioLq6dWhRd DPThFVt8UzRBUnyK/afuRop1dx5ZpmVKxLe29q8bs4SAmFaQR5aNAdvHzAeCXBAWn1d4 pqMd0rSFv2FKBgy8quIF4elmlwiDGceTp7vVFHE3FNNBk8B0YjV19JXoNZ096PTB1a18 UH+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=mBnNW8oub18hKhhe8yHqfoSEZU2iRCB395w7gjgwxWc=; b=BoyiVuLaZHc6hSomMH9JfBN/vjgytbazyW5j8EFZsGj5uXBPmxYgps9YZ8ZqAe6/dd hn3729QLD+kxxlTh7uFLxMCMf8qNeBTQZr6P6fWEIOgIg+3U3FkhSHDGYyVVEs1dFi6e Um3M79nMuGaSKtz8WgZ1zpDlGvHbzQFBS4eQrAgwjlDX6YbHO0Awzp3zFmJyCSVZ/5ZS ZrwPCue2N+azweOrpeNUENKOhNicxVWZKkkDJGE/tksfELbWb7Oz1nBsZKjcHz/knvpe AMWGeMMucMEkTY8XHj3MUCeUQxZVc26TyxQWyH5HdtzS0lSSz9iPV9CRt5wVufaH0VTS ctBA== X-Gm-Message-State: AOAM533DKIh3qyNOoovedzhANo5yshWsAinyecH02uakIrkJHRYeMgw9 yNcWxP/idYiS0lgUopZUUKN76/0he45G Sender: "lenaptr via sendgmr" X-Received: from beef.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1091]) (user=lenaptr job=sendgmr) by 2002:a1c:2c89:: with SMTP id s131mr533256wms.0.1610645093881; Thu, 14 Jan 2021 09:24:53 -0800 (PST) Date: Thu, 14 Jan 2021 17:23:36 +0000 In-Reply-To: <20210114172338.2798389-1-lenaptr@google.com> Message-Id: <20210114172338.2798389-7-lenaptr@google.com> Mime-Version: 1.0 References: <20210114172338.2798389-1-lenaptr@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH v2 6/9] KVM: arm64: __ubsan_handle_load_invalid_value EL2 implementation. From: Elena Petrova To: kvmarm@lists.cs.columbia.edu Cc: Elena Petrova , linux-arm-kernel@lists.infradead.org, open list , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , George Popescu , George Popescu Content-Type: text/plain; charset="UTF-8" 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 at EL2. The EL2 handler's parameters are stored inside the buffer. They are used by the symetric handler from EL1. Signed-off-by: George Popescu Signed-off-by: Elena Petrova --- arch/arm64/include/asm/kvm_ubsan.h | 5 ++++- arch/arm64/kvm/hyp/nvhe/ubsan.c | 14 +++++++++++++- arch/arm64/kvm/kvm_ubsan_buffer.c | 6 +++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/kvm_ubsan.h b/arch/arm64/include/asm/kvm_ubsan.h index 0eef0e11a93b..95ac6728ffd1 100644 --- a/arch/arm64/include/asm/kvm_ubsan.h +++ b/arch/arm64/include/asm/kvm_ubsan.h @@ -20,12 +20,14 @@ struct kvm_ubsan_info { enum { 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; @@ -35,3 +37,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 1069ed5036d5..3143f7722be2 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 b80045883047..5439f7a91636 100644 --- a/arch/arm64/kvm/kvm_ubsan_buffer.c +++ b/arch/arm64/kvm/kvm_ubsan_buffer.c @@ -31,7 +31,11 @@ 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; + } } void iterate_kvm_ubsan_buffer(unsigned long left, unsigned long right) -- 2.30.0.284.gd98b1dd5eaa7-goog