soc: qcom: hab: Add HAB fixes, and workarounds, for GHS

Fix kernel shutdown callback crash in HAB by removing
commdev freeing in pchan free.
Add stub functions for dump_hab_wq and hab_pipe_read_dump.

Change-Id: I176085600e3ec3a40eb2f181491405c6bf4ac7bb
Signed-off-by: Anant Goel <anantg@codeaurora.org>
Signed-off-by: Zhiqiang Tu <ztu@codeaurora.org>
Signed-off-by: Yong Ding <yongding@codeaurora.org>
This commit is contained in:
Zhiqiang Tu 2020-12-02 09:54:23 +08:00 • committed by Gerrit - the friendly Code Review server
commit 4f02b73d10
5 changed files with 28 additions and 7 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include "hab.h"
#include "hab_ghs.h"
@ -34,7 +34,15 @@ int physical_channel_send(struct physical_channel *pchan,
struct ghs_vdev *dev = (struct ghs_vdev *)pchan->hyp_data;
GIPC_Result result;
uint8_t *msg;
int irqs_disabled = irqs_disabled();
int irqs_disabled;
if (!dev) {
pr_err("no send pchan %s has been de-alloced msg for %zd bytes\n",
pchan->name);
return -ENODEV;
}
irqs_disabled = irqs_disabled();
hab_spin_lock(&dev->io_lock, irqs_disabled);
@ -94,7 +102,15 @@ void physical_channel_rx_dispatch_common(unsigned long physical_channel)
(struct physical_channel *)physical_channel;
struct ghs_vdev *dev = (struct ghs_vdev *)pchan->hyp_data;
GIPC_Result result;
int irqs_disabled = irqs_disabled();
int irqs_disabled;
if (!dev) {
pr_err("no recv pchan %s has been de-alloced msg for %zd bytes\n",
pchan->name);
return;
}
irqs_disabled = irqs_disabled();
hab_spin_lock(&pchan->rxbuf_lock, irqs_disabled);
while (1) {

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include "hab.h"
#include "hab_ghs.h"
@ -164,6 +164,9 @@ int habhyp_commdev_dealloc(void *commdev)
kfree(dev->os_data);
kfree(dev);
pchan->closed = 1;
pchan->hyp_data = NULL;
if (get_refcnt(pchan->refcount) > 1) {
pr_warn("potential leak pchan %s vchans %d refcnt %d\n",
pchan->name, pchan->vcnt, get_refcnt(pchan->refcount));

View file

@ -150,3 +150,6 @@ int hab_hypervisor_register_os(void)
return 0;
}
void dump_hab_wq(void *hyp_data) {};
void hab_pipe_read_dump(struct physical_channel *pchan) {};

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
*/
#include "hab.h"
@ -59,7 +59,6 @@ static void hab_pchan_free(struct kref *ref)
}
read_unlock(&pchan->vchans_lock);
kfree(pchan->hyp_data);
kfree(pchan);
}

View file

@ -3,10 +3,10 @@
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include "hab.h"
#include <linux/rtc.h>
#if !defined CONFIG_GHS_VMM && defined(CONFIG_QTI_QUIN_GVM)
#include <asm/cacheflush.h>
#include <linux/list.h>
#include <linux/rtc.h>
#include "hab_pipe.h"
#include "hab_qvm.h"
#include "khab_test.h"