From: Rob Gardner Date: Wed, 19 Apr 2017 17:21:13 +0000 (-0600) Subject: sparc64: Disable DAX flow control X-Git-Tag: v4.1.12-98.0.20170517_2143~33^2~2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=03cf00ebf89e405bbd8a6b0112cc4c99ed4f4d1e;p=users%2Fjedix%2Flinux-maple.git sparc64: Disable DAX flow control Orabug: 25997202 The flow control feature of DAX only works for output buffers and it doesn't appear to be possible to calculate the exact size in bytes of an input buffer. So we have no way to bound the amount of data that DAX reads as input. This has correctness and security implications, so until we figure out something better to do, the temporary workaround is to disable flow control completely and fall back to 4Mb virtual page backed dax_alloc memory, which will allow page boundaries to limit the size of all buffers. A new module parameter "flow_enable" is provided to allow this decision to be reverted at module load time if needed. Signed-off-by: Rob Gardner Reviewed-by: Jonathan Helman Reviewed-by: Sanath Kumar Signed-off-by: Allen Pais --- diff --git a/arch/sparc/dax/dax_main.c b/arch/sparc/dax/dax_main.c index 87c345dffdf87..078ea1ce92653 100644 --- a/arch/sparc/dax/dax_main.c +++ b/arch/sparc/dax/dax_main.c @@ -50,6 +50,9 @@ module_param(force, int, 0644); MODULE_PARM_DESC(force, "Forces module loading if no device present"); module_param(dax_debug, int, 0644); MODULE_PARM_DESC(dax_debug, "Debug flags"); +static int flow_enable = 0; +module_param(flow_enable, int, 0644); +MODULE_PARM_DESC(flow_enable, "Enables flow control if hardware supports it"); static const struct file_operations dax_fops = { .owner = THIS_MODULE, @@ -163,8 +166,11 @@ static int __init dax_attach(void) * MD does not report it in old versions of HV, we need to explicitly * check for flow control feature. */ - if ((dax_type == DAX1) && !dax_has_flow_ctl_numa()) { - dax_dbg("Flow control disabled, dax_alloc restricted to 4M"); + if (!flow_enable) { + dax_dbg("Flow control disabled by software, dax_alloc restricted to 4M"); + dax_no_flow_ctl = true; + } else if ((dax_type == DAX1) && !dax_has_flow_ctl_numa()) { + dax_dbg("Flow control disabled by hardware, dax_alloc restricted to 4M"); dax_no_flow_ctl = true; } else { dax_dbg("Flow control enabled"); diff --git a/arch/sparc/dax/dax_mm.c b/arch/sparc/dax/dax_mm.c index 480c07b949cca..890e2c4d8e523 100644 --- a/arch/sparc/dax/dax_mm.c +++ b/arch/sparc/dax/dax_mm.c @@ -249,11 +249,7 @@ void dax_map_segment(struct dax_ctx *dax_ctx, union ccb *ccb, size_t ccb_len) } if (hdr->at_src0 == CCB_AT_VA_ALT) { - access = (struct ccb_data_acc_ctl *) - &ccbp->dwords[QUERY_DWORD_DAC]; - /* size in bytes */ - size = DAX_IN_SIZE_FROM_CCB(access->input_cnt); - if (dax_map_segment_common(size, &ccb_addr_type, "src0", + if (dax_map_segment_common(0, &ccb_addr_type, "src0", QUERY_DWORD_INPUT, ccbp, dax_ctx) == 0) hdr->at_src0 = ccb_addr_type;