···55-----6677Hardware issues which result in security problems are a different category88-of security bugs than pure software bugs which only affect the Linux88+of security bugs than pure software bugs which only affect the Linux99kernel.10101111Hardware issues like Meltdown, Spectre, L1TF etc. must be treated···159159160160The initial response team sets up an encrypted mailing-list or repurposes161161an existing one if appropriate. The disclosing party should provide a list162162-of contacts for all other parties who have already been, or should be162162+of contacts for all other parties who have already been, or should be,163163informed about the issue. The response team contacts these parties so they164164can name experts who should be subscribed to the mailing-list.165165···217217 AMD218218 IBM219219 Intel220220- Qualcomm220220+ Qualcomm Trilok Soni <tsoni@codeaurora.org>221221222222- Microsoft222222+ Microsoft Sasha Levin <sashal@kernel.org>223223 VMware224224- XEN224224+ Xen Andrew Cooper <andrew.cooper3@citrix.com>225225226226 Canonical Tyler Hicks <tyhicks@canonical.com>227227 Debian Ben Hutchings <ben@decadent.org.uk>···230230 SUSE Jiri Kosina <jkosina@suse.cz>231231232232 Amazon233233- Google234234- ============== ========================================================233233+ Google Kees Cook <keescook@chromium.org>234234+ ============= ========================================================235235236236If you want your organization to be added to the ambassadors list, please237237contact the hardware security team. The nominated ambassador has to
+7-6
Documentation/riscv/boot-image-header.txt
···1818 u32 res1 = 0; /* Reserved */1919 u64 res2 = 0; /* Reserved */2020 u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" */2121- u32 res3; /* Reserved for additional RISC-V specific header */2121+ u32 magic2 = 0x56534905; /* Magic number 2, little endian, "RSC\x05" */2222 u32 res4; /* Reserved for PE COFF offset */23232424This header format is compliant with PE/COFF header and largely inspired from···3737 Bits 16:31 - Major version38383939 This preserves compatibility across newer and older version of the header.4040- The current version is defined as 0.1.4040+ The current version is defined as 0.2.41414242-- res3 is reserved for offset to any other additional fields. This makes the4343- header extendible in future. One example would be to accommodate ISA4444- extension for RISC-V in future. For current version, it is set to be zero.4242+- The "magic" field is deprecated as of version 0.2. In a future4343+ release, it may be removed. This originally should have matched up4444+ with the ARM64 header "magic" field, but unfortunately does not.4545+ The "magic2" field replaces it, matching up with the ARM64 header.45464646-- In current header, the flag field has only one field.4747+- In current header, the flags field has only one field.4748 Bit 0: Kernel endianness. 1 if BE, 0 if LE.48494950- Image size is mandatory for boot loader to load kernel image. Booting will
+1-2
MAINTAINERS
···1773217732F: include/uapi/linux/fsmap.h17733177331773417734XILINX AXI ETHERNET DRIVER1773517735-M: Anirudha Sarangi <anirudh@xilinx.com>1773617736-M: John Linn <John.Linn@xilinx.com>1773517735+M: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>1773717736S: Maintained1773817737F: drivers/net/ethernet/xilinx/xilinx_axienet*1773917738
···630630#ifdef CONFIG_PPC_FSL_BOOK3E631631 if (mmu_has_feature(MMU_FTR_TYPE_FSL_E)) {632632 unsigned int num_cams;633633- int __maybe_unused cpu = smp_processor_id();634633 bool map = true;635634636635 /* use a quarter of the TLBCAM for bolted linear map */
+6-6
arch/riscv/include/asm/image.h
···33#ifndef __ASM_IMAGE_H44#define __ASM_IMAGE_H5566-#define RISCV_IMAGE_MAGIC "RISCV"66+#define RISCV_IMAGE_MAGIC "RISCV\0\0\0"77+#define RISCV_IMAGE_MAGIC2 "RSC\x05"7889#define RISCV_IMAGE_FLAG_BE_SHIFT 0910#define RISCV_IMAGE_FLAG_BE_MASK 0x1···2423#define __HEAD_FLAGS (__HEAD_FLAG(BE))25242625#define RISCV_HEADER_VERSION_MAJOR 02727-#define RISCV_HEADER_VERSION_MINOR 12626+#define RISCV_HEADER_VERSION_MINOR 228272928#define RISCV_HEADER_VERSION (RISCV_HEADER_VERSION_MAJOR << 16 | \3029 RISCV_HEADER_VERSION_MINOR)···4039 * @version: version4140 * @res1: reserved4241 * @res2: reserved4343- * @magic: Magic number4444- * @res3: reserved (will be used for additional RISC-V specific4545- * header)4242+ * @magic: Magic number (RISC-V specific; deprecated)4343+ * @magic2: Magic number 2 (to match the ARM64 'magic' field pos)4644 * @res4: reserved (will be used for PE COFF offset)4745 *4846 * The intention is for this header format to be shared between multiple···5858 u32 res1;5959 u64 res2;6060 u64 magic;6161- u32 res3;6161+ u32 magic2;6262 u32 res4;6363};6464#endif /* __ASSEMBLY__ */
···19611961 case KVM_S390_MCHK:19621962 irq->u.mchk.mcic = s390int->parm64;19631963 break;19641964+ case KVM_S390_INT_PFAULT_INIT:19651965+ irq->u.ext.ext_params = s390int->parm;19661966+ irq->u.ext.ext_params2 = s390int->parm64;19671967+ break;19681968+ case KVM_S390_RESTART:19691969+ case KVM_S390_INT_CLOCK_COMP:19701970+ case KVM_S390_INT_CPU_TIMER:19711971+ break;19721972+ default:19731973+ return -EINVAL;19641974 }19651975 return 0;19661976}
+3-1
arch/s390/kvm/kvm-s390.c
···10181018 /* mark all the pages in active slots as dirty */10191019 for (slotnr = 0; slotnr < slots->used_slots; slotnr++) {10201020 ms = slots->memslots + slotnr;10211021+ if (!ms->dirty_bitmap)10221022+ return -EINVAL;10211023 /*10221024 * The second half of the bitmap is only used on x86,10231025 * and would be wasted otherwise, so we put it to good···43254323 }43264324 case KVM_S390_INTERRUPT: {43274325 struct kvm_s390_interrupt s390int;43284328- struct kvm_s390_irq s390irq;43264326+ struct kvm_s390_irq s390irq = {};4329432743304328 if (copy_from_user(&s390int, argp, sizeof(s390int)))43314329 return -EFAULT;
···3737 * Lower 12 bits encode the number of additional3838 * pages to flush (in addition to the 'cur' page).3939 */4040- if (diff >= HV_TLB_FLUSH_UNIT)4040+ if (diff >= HV_TLB_FLUSH_UNIT) {4141 gva_list[gva_n] |= ~PAGE_MASK;4242- else if (diff)4242+ cur += HV_TLB_FLUSH_UNIT;4343+ } else if (diff) {4344 gva_list[gva_n] |= (diff - 1) >> PAGE_SHIFT;4545+ cur = end;4646+ }44474545- cur += HV_TLB_FLUSH_UNIT;4648 gva_n++;47494850 } while (cur < end);
···335335 int root_count; /* Currently serving as active root */336336 unsigned int unsync_children;337337 struct kvm_rmap_head parent_ptes; /* rmap pointers to parent sptes */338338+ unsigned long mmu_valid_gen;338339 DECLARE_BITMAP(unsync_child_bitmap, 512);339340340341#ifdef CONFIG_X86_32···857856 unsigned long n_requested_mmu_pages;858857 unsigned long n_max_mmu_pages;859858 unsigned int indirect_shadow_pages;859859+ unsigned long mmu_valid_gen;860860 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];861861 /*862862 * Hash table of struct kvm_mmu_page.
···834834 if (!boot_cpu_has(X86_FEATURE_APIC))835835 return true;836836837837+ /* Virt guests may lack ARAT, but still have DEADLINE */838838+ if (!boot_cpu_has(X86_FEATURE_ARAT))839839+ return true;840840+837841 /* Deadline timer is based on TSC so no further PIT action required */838842 if (boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER))839843 return false;···11831179 apic_write(APIC_LVT0, v | APIC_LVT_MASKED);11841180 v = apic_read(APIC_LVT1);11851181 apic_write(APIC_LVT1, v | APIC_LVT_MASKED);11861186- if (!x2apic_enabled()) {11871187- v = apic_read(APIC_LDR) & ~APIC_LDR_MASK;11881188- apic_write(APIC_LDR, v);11891189- }11901182 if (maxlvt >= 4) {11911183 v = apic_read(APIC_LVTPC);11921184 apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
+99-2
arch/x86/kvm/mmu.c
···20952095 if (!direct)20962096 sp->gfns = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_cache);20972097 set_page_private(virt_to_page(sp->spt), (unsigned long)sp);20982098+20992099+ /*21002100+ * active_mmu_pages must be a FIFO list, as kvm_zap_obsolete_pages()21012101+ * depends on valid pages being added to the head of the list. See21022102+ * comments in kvm_zap_obsolete_pages().21032103+ */20982104 list_add(&sp->link, &vcpu->kvm->arch.active_mmu_pages);20992105 kvm_mod_used_mmu_pages(vcpu->kvm, +1);21002106 return sp;···22502244#define for_each_valid_sp(_kvm, _sp, _gfn) \22512245 hlist_for_each_entry(_sp, \22522246 &(_kvm)->arch.mmu_page_hash[kvm_page_table_hashfn(_gfn)], hash_link) \22532253- if ((_sp)->role.invalid) { \22472247+ if (is_obsolete_sp((_kvm), (_sp)) || (_sp)->role.invalid) { \22542248 } else2255224922562250#define for_each_gfn_indirect_valid_sp(_kvm, _sp, _gfn) \···23062300static void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point) { }23072301static void mmu_audit_disable(void) { }23082302#endif23032303+23042304+static bool is_obsolete_sp(struct kvm *kvm, struct kvm_mmu_page *sp)23052305+{23062306+ return unlikely(sp->mmu_valid_gen != kvm->arch.mmu_valid_gen);23072307+}2309230823102309static bool kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,23112310 struct list_head *invalid_list)···25362525 if (level > PT_PAGE_TABLE_LEVEL && need_sync)25372526 flush |= kvm_sync_pages(vcpu, gfn, &invalid_list);25382527 }25282528+ sp->mmu_valid_gen = vcpu->kvm->arch.mmu_valid_gen;25392529 clear_page(sp->spt);25402530 trace_kvm_mmu_get_page(sp, true);25412531···42454233 return false;4246423442474235 if (cached_root_available(vcpu, new_cr3, new_role)) {42364236+ /*42374237+ * It is possible that the cached previous root page is42384238+ * obsolete because of a change in the MMU generation42394239+ * number. However, changing the generation number is42404240+ * accompanied by KVM_REQ_MMU_RELOAD, which will free42414241+ * the root set here and allocate a new one.42424242+ */42484243 kvm_make_request(KVM_REQ_LOAD_CR3, vcpu);42494244 if (!skip_tlb_flush) {42504245 kvm_make_request(KVM_REQ_MMU_SYNC, vcpu);···56685649 return alloc_mmu_pages(vcpu);56695650}5670565156525652+56535653+static void kvm_zap_obsolete_pages(struct kvm *kvm)56545654+{56555655+ struct kvm_mmu_page *sp, *node;56565656+ LIST_HEAD(invalid_list);56575657+ int ign;56585658+56595659+restart:56605660+ list_for_each_entry_safe_reverse(sp, node,56615661+ &kvm->arch.active_mmu_pages, link) {56625662+ /*56635663+ * No obsolete valid page exists before a newly created page56645664+ * since active_mmu_pages is a FIFO list.56655665+ */56665666+ if (!is_obsolete_sp(kvm, sp))56675667+ break;56685668+56695669+ /*56705670+ * Do not repeatedly zap a root page to avoid unnecessary56715671+ * KVM_REQ_MMU_RELOAD, otherwise we may not be able to56725672+ * progress:56735673+ * vcpu 0 vcpu 156745674+ * call vcpu_enter_guest():56755675+ * 1): handle KVM_REQ_MMU_RELOAD56765676+ * and require mmu-lock to56775677+ * load mmu56785678+ * repeat:56795679+ * 1): zap root page and56805680+ * send KVM_REQ_MMU_RELOAD56815681+ *56825682+ * 2): if (cond_resched_lock(mmu-lock))56835683+ *56845684+ * 2): hold mmu-lock and load mmu56855685+ *56865686+ * 3): see KVM_REQ_MMU_RELOAD bit56875687+ * on vcpu->requests is set56885688+ * then return 1 to call56895689+ * vcpu_enter_guest() again.56905690+ * goto repeat;56915691+ *56925692+ * Since we are reversely walking the list and the invalid56935693+ * list will be moved to the head, skip the invalid page56945694+ * can help us to avoid the infinity list walking.56955695+ */56965696+ if (sp->role.invalid)56975697+ continue;56985698+56995699+ if (need_resched() || spin_needbreak(&kvm->mmu_lock)) {57005700+ kvm_mmu_commit_zap_page(kvm, &invalid_list);57015701+ cond_resched_lock(&kvm->mmu_lock);57025702+ goto restart;57035703+ }57045704+57055705+ if (__kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list, &ign))57065706+ goto restart;57075707+ }57085708+57095709+ kvm_mmu_commit_zap_page(kvm, &invalid_list);57105710+}57115711+57125712+/*57135713+ * Fast invalidate all shadow pages and use lock-break technique57145714+ * to zap obsolete pages.57155715+ *57165716+ * It's required when memslot is being deleted or VM is being57175717+ * destroyed, in these cases, we should ensure that KVM MMU does57185718+ * not use any resource of the being-deleted slot or all slots57195719+ * after calling the function.57205720+ */57215721+static void kvm_mmu_zap_all_fast(struct kvm *kvm)57225722+{57235723+ spin_lock(&kvm->mmu_lock);57245724+ kvm->arch.mmu_valid_gen++;57255725+57265726+ kvm_zap_obsolete_pages(kvm);57275727+ spin_unlock(&kvm->mmu_lock);57285728+}57295729+56715730static void kvm_mmu_invalidate_zap_pages_in_memslot(struct kvm *kvm,56725731 struct kvm_memory_slot *slot,56735732 struct kvm_page_track_notifier_node *node)56745733{56755675- kvm_mmu_zap_all(kvm);57345734+ kvm_mmu_zap_all_fast(kvm);56765735}5677573656785737void kvm_mmu_init_vm(struct kvm *kvm)
+3-1
arch/x86/kvm/vmx/nested.c
···45404540 int len;45414541 gva_t gva = 0;45424542 struct vmcs12 *vmcs12;45434543+ struct x86_exception e;45434544 short offset;4544454545454546 if (!nested_vmx_check_permission(vcpu))···45894588 vmx_instruction_info, true, len, &gva))45904589 return 1;45914590 /* _system ok, nested_vmx_check_permission has verified cpl=0 */45924592- kvm_write_guest_virt_system(vcpu, gva, &field_value, len, NULL);45914591+ if (kvm_write_guest_virt_system(vcpu, gva, &field_value, len, &e))45924592+ kvm_inject_page_fault(vcpu, &e);45934593 }4594459445954595 return nested_vmx_succeed(vcpu);
+7
arch/x86/kvm/x86.c
···53125312 /* kvm_write_guest_virt_system can pull in tons of pages. */53135313 vcpu->arch.l1tf_flush_l1d = true;5314531453155315+ /*53165316+ * FIXME: this should call handle_emulation_failure if X86EMUL_IO_NEEDED53175317+ * is returned, but our callers are not ready for that and they blindly53185318+ * call kvm_inject_page_fault. Ensure that they at least do not leak53195319+ * uninitialized kernel stack memory into cr2 and error code.53205320+ */53215321+ memset(exception, 0, sizeof(*exception));53155322 return kvm_write_guest_virt_helper(addr, val, bytes, vcpu,53165323 PFERR_WRITE_MASK, exception);53175324}
+19-16
arch/x86/purgatory/Makefile
···1818KASAN_SANITIZE := n1919KCOV_INSTRUMENT := n20202121+# These are adjustments to the compiler flags used for objects that2222+# make up the standalone purgatory.ro2323+2424+PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel2525+PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss2626+2127# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That2228# in turn leaves some undefined symbols like __fentry__ in purgatory and not2329# sure how to relocate those.2430ifdef CONFIG_FUNCTION_TRACER2525-CFLAGS_REMOVE_sha256.o += $(CC_FLAGS_FTRACE)2626-CFLAGS_REMOVE_purgatory.o += $(CC_FLAGS_FTRACE)2727-CFLAGS_REMOVE_string.o += $(CC_FLAGS_FTRACE)2828-CFLAGS_REMOVE_kexec-purgatory.o += $(CC_FLAGS_FTRACE)3131+PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_FTRACE)2932endif30333134ifdef CONFIG_STACKPROTECTOR3232-CFLAGS_REMOVE_sha256.o += -fstack-protector3333-CFLAGS_REMOVE_purgatory.o += -fstack-protector3434-CFLAGS_REMOVE_string.o += -fstack-protector3535-CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector3535+PURGATORY_CFLAGS_REMOVE += -fstack-protector3636endif37373838ifdef CONFIG_STACKPROTECTOR_STRONG3939-CFLAGS_REMOVE_sha256.o += -fstack-protector-strong4040-CFLAGS_REMOVE_purgatory.o += -fstack-protector-strong4141-CFLAGS_REMOVE_string.o += -fstack-protector-strong4242-CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector-strong3939+PURGATORY_CFLAGS_REMOVE += -fstack-protector-strong4340endif44414542ifdef CONFIG_RETPOLINE4646-CFLAGS_REMOVE_sha256.o += $(RETPOLINE_CFLAGS)4747-CFLAGS_REMOVE_purgatory.o += $(RETPOLINE_CFLAGS)4848-CFLAGS_REMOVE_string.o += $(RETPOLINE_CFLAGS)4949-CFLAGS_REMOVE_kexec-purgatory.o += $(RETPOLINE_CFLAGS)4343+PURGATORY_CFLAGS_REMOVE += $(RETPOLINE_CFLAGS)5044endif4545+4646+CFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE)4747+CFLAGS_purgatory.o += $(PURGATORY_CFLAGS)4848+4949+CFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE)5050+CFLAGS_sha256.o += $(PURGATORY_CFLAGS)5151+5252+CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE)5353+CFLAGS_string.o += $(PURGATORY_CFLAGS)51545255$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE5356 $(call if_changed,ld)
···384384 { USB_DEVICE(0x13d3, 0x3526), .driver_info = BTUSB_REALTEK },385385 { USB_DEVICE(0x0b05, 0x185c), .driver_info = BTUSB_REALTEK },386386387387+ /* Additional Realtek 8822CE Bluetooth devices */388388+ { USB_DEVICE(0x04ca, 0x4005), .driver_info = BTUSB_REALTEK },389389+387390 /* Silicon Wave based devices */388391 { USB_DEVICE(0x0c10, 0x0000), .driver_info = BTUSB_SWAVE },389392···12041201 }1205120212061203 data->intf->needs_remote_wakeup = 1;12071207- /* device specific wakeup source enabled and required for USB12081208- * remote wakeup while host is suspended12091209- */12101210- device_wakeup_enable(&data->udev->dev);1211120412121205 /* Disable device remote wakeup when host is suspended12131206 * For Realtek chips, global suspend without···12801281 if (test_bit(BTUSB_WAKEUP_DISABLE, &data->flags))12811282 data->intf->needs_remote_wakeup = 1;1282128312831283- device_wakeup_disable(&data->udev->dev);12841284 usb_autopm_put_interface(data->intf);1285128512861286failed:
+6-4
drivers/bluetooth/hci_qca.c
···309309 ws_awake_device);310310 struct hci_uart *hu = qca->hu;311311 unsigned long retrans_delay;312312+ unsigned long flags;312313313314 BT_DBG("hu %p wq awake device", hu);314315315316 /* Vote for serial clock */316317 serial_clock_vote(HCI_IBS_TX_VOTE_CLOCK_ON, hu);317318318318- spin_lock(&qca->hci_ibs_lock);319319+ spin_lock_irqsave(&qca->hci_ibs_lock, flags);319320320321 /* Send wake indication to device */321322 if (send_hci_ibs_cmd(HCI_IBS_WAKE_IND, hu) < 0)···328327 retrans_delay = msecs_to_jiffies(qca->wake_retrans);329328 mod_timer(&qca->wake_retrans_timer, jiffies + retrans_delay);330329331331- spin_unlock(&qca->hci_ibs_lock);330330+ spin_unlock_irqrestore(&qca->hci_ibs_lock, flags);332331333332 /* Actually send the packets */334333 hci_uart_tx_wakeup(hu);···339338 struct qca_data *qca = container_of(work, struct qca_data,340339 ws_awake_rx);341340 struct hci_uart *hu = qca->hu;341341+ unsigned long flags;342342343343 BT_DBG("hu %p wq awake rx", hu);344344345345 serial_clock_vote(HCI_IBS_RX_VOTE_CLOCK_ON, hu);346346347347- spin_lock(&qca->hci_ibs_lock);347347+ spin_lock_irqsave(&qca->hci_ibs_lock, flags);348348 qca->rx_ibs_state = HCI_IBS_RX_AWAKE;349349350350 /* Always acknowledge device wake up,···356354357355 qca->ibs_sent_wacks++;358356359359- spin_unlock(&qca->hci_ibs_lock);357357+ spin_unlock_irqrestore(&qca->hci_ibs_lock, flags);360358361359 /* Actually send the packets */362360 hci_uart_tx_wakeup(hu);
+19-9
drivers/dma/sh/rcar-dmac.c
···192192 * @iomem: remapped I/O memory base193193 * @n_channels: number of available channels194194 * @channels: array of DMAC channels195195+ * @channels_mask: bitfield of which DMA channels are managed by this driver195196 * @modules: bitmask of client modules in use196197 */197198struct rcar_dmac {···203202204203 unsigned int n_channels;205204 struct rcar_dmac_chan *channels;205205+ unsigned int channels_mask;206206207207 DECLARE_BITMAP(modules, 256);208208};···440438 u16 dmaor;441439442440 /* Clear all channels and enable the DMAC globally. */443443- rcar_dmac_write(dmac, RCAR_DMACHCLR, GENMASK(dmac->n_channels - 1, 0));441441+ rcar_dmac_write(dmac, RCAR_DMACHCLR, dmac->channels_mask);444442 rcar_dmac_write(dmac, RCAR_DMAOR,445443 RCAR_DMAOR_PRI_FIXED | RCAR_DMAOR_DME);446444···815813 /* Stop all channels. */816814 for (i = 0; i < dmac->n_channels; ++i) {817815 struct rcar_dmac_chan *chan = &dmac->channels[i];816816+817817+ if (!(dmac->channels_mask & BIT(i)))818818+ continue;818819819820 /* Stop and reinitialize the channel. */820821 spin_lock_irq(&chan->lock);···17811776 return 0;17821777}1783177817791779+#define RCAR_DMAC_MAX_CHANNELS 3217801780+17841781static int rcar_dmac_parse_of(struct device *dev, struct rcar_dmac *dmac)17851782{17861783 struct device_node *np = dev->of_node;···17941787 return ret;17951788 }1796178917971797- if (dmac->n_channels <= 0 || dmac->n_channels >= 100) {17901790+ /* The hardware and driver don't support more than 32 bits in CHCLR */17911791+ if (dmac->n_channels <= 0 ||17921792+ dmac->n_channels >= RCAR_DMAC_MAX_CHANNELS) {17981793 dev_err(dev, "invalid number of channels %u\n",17991794 dmac->n_channels);18001795 return -EINVAL;18011796 }17971797+17981798+ dmac->channels_mask = GENMASK(dmac->n_channels - 1, 0);1802179918031800 return 0;18041801}···18131802 DMA_SLAVE_BUSWIDTH_2_BYTES | DMA_SLAVE_BUSWIDTH_4_BYTES |18141803 DMA_SLAVE_BUSWIDTH_8_BYTES | DMA_SLAVE_BUSWIDTH_16_BYTES |18151804 DMA_SLAVE_BUSWIDTH_32_BYTES | DMA_SLAVE_BUSWIDTH_64_BYTES;18161816- unsigned int channels_offset = 0;18171805 struct dma_device *engine;18181806 struct rcar_dmac *dmac;18191807 struct resource *mem;···18411831 * level we can't disable it selectively, so ignore channel 0 for now if18421832 * the device is part of an IOMMU group.18431833 */18441844- if (device_iommu_mapped(&pdev->dev)) {18451845- dmac->n_channels--;18461846- channels_offset = 1;18471847- }18341834+ if (device_iommu_mapped(&pdev->dev))18351835+ dmac->channels_mask &= ~BIT(0);1848183618491837 dmac->channels = devm_kcalloc(&pdev->dev, dmac->n_channels,18501838 sizeof(*dmac->channels), GFP_KERNEL);···19001892 INIT_LIST_HEAD(&engine->channels);1901189319021894 for (i = 0; i < dmac->n_channels; ++i) {19031903- ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i],19041904- i + channels_offset);18951895+ if (!(dmac->channels_mask & BIT(i)))18961896+ continue;18971897+18981898+ ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i], i);19051899 if (ret < 0)19061900 goto error;19071901 }
+8-2
drivers/dma/sprd-dma.c
···908908 struct sprd_dma_chn *schan = to_sprd_dma_chan(chan);909909 struct dma_slave_config *slave_cfg = &schan->slave_cfg;910910 dma_addr_t src = 0, dst = 0;911911+ dma_addr_t start_src = 0, start_dst = 0;911912 struct sprd_dma_desc *sdesc;912913 struct scatterlist *sg;913914 u32 len = 0;···955954 dst = sg_dma_address(sg);956955 }957956957957+ if (!i) {958958+ start_src = src;959959+ start_dst = dst;960960+ }961961+958962 /*959963 * The link-list mode needs at least 2 link-list960964 * configurations. If there is only one sg, it doesn't···976970 }977971 }978972979979- ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, src, dst, len,980980- dir, flags, slave_cfg);973973+ ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, start_src,974974+ start_dst, len, dir, flags, slave_cfg);981975 if (ret) {982976 kfree(sdesc);983977 return NULL;
+3-1
drivers/dma/ti/dma-crossbar.c
···391391392392 ret = of_property_read_u32_array(node, pname, (u32 *)rsv_events,393393 nelm * 2);394394- if (ret)394394+ if (ret) {395395+ kfree(rsv_events);395396 return ret;397397+ }396398397399 for (i = 0; i < nelm; i++) {398400 ti_dra7_xbar_reserve(rsv_events[i][0], rsv_events[i][1],
+3-1
drivers/dma/ti/omap-dma.c
···1540154015411541 rc = devm_request_irq(&pdev->dev, irq, omap_dma_irq,15421542 IRQF_SHARED, "omap-dma-engine", od);15431543- if (rc)15431543+ if (rc) {15441544+ omap_dma_free(od);15441545 return rc;15461546+ }15451547 }1546154815471549 if (omap_dma_glbl_read(od, CAPS_0) & CAPS_0_SUPPORT_LL123)
···604604 u8 new_irqs;605605 int level, i;606606 u8 invert_irq_mask[MAX_BANK];607607- int reg_direction[MAX_BANK];607607+ u8 reg_direction[MAX_BANK];608608609609- regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,610610- NBANK(chip));609609+ pca953x_read_regs(chip, chip->regs->direction, reg_direction);611610612611 if (chip->driver_data & PCA_PCAL) {613612 /* Enable latch on interrupt-enabled inputs */···678679 bool pending_seen = false;679680 bool trigger_seen = false;680681 u8 trigger[MAX_BANK];681681- int reg_direction[MAX_BANK];682682+ u8 reg_direction[MAX_BANK];682683 int ret, i;683684684685 if (chip->driver_data & PCA_PCAL) {···709710 return false;710711711712 /* Remove output pins from the equation */712712- regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,713713- NBANK(chip));713713+ pca953x_read_regs(chip, chip->regs->direction, reg_direction);714714 for (i = 0; i < NBANK(chip); i++)715715 cur_stat[i] &= reg_direction[i];716716···766768{767769 struct i2c_client *client = chip->client;768770 struct irq_chip *irq_chip = &chip->irq_chip;769769- int reg_direction[MAX_BANK];771771+ u8 reg_direction[MAX_BANK];770772 int ret, i;771773772774 if (!client->irq)···787789 * interrupt. We have to rely on the previous read for788790 * this purpose.789791 */790790- regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,791791- NBANK(chip));792792+ pca953x_read_regs(chip, chip->regs->direction, reg_direction);792793 for (i = 0; i < NBANK(chip); i++)793794 chip->irq_stat[i] &= reg_direction[i];794795 mutex_init(&chip->irq_lock);
+38-4
drivers/gpio/gpiolib-acpi.c
···77 * Mika Westerberg <mika.westerberg@linux.intel.com>88 */991010+#include <linux/dmi.h>1011#include <linux/errno.h>1112#include <linux/gpio/consumer.h>1213#include <linux/gpio/driver.h>···1918#include <linux/pinctrl/pinctrl.h>20192120#include "gpiolib.h"2121+2222+static int run_edge_events_on_boot = -1;2323+module_param(run_edge_events_on_boot, int, 0444);2424+MODULE_PARM_DESC(run_edge_events_on_boot,2525+ "Run edge _AEI event-handlers at boot: 0=no, 1=yes, -1=auto");22262327/**2428 * struct acpi_gpio_event - ACPI GPIO event handler data···176170 event->irq_requested = true;177171178172 /* Make sure we trigger the initial state of edge-triggered IRQs */179179- value = gpiod_get_raw_value_cansleep(event->desc);180180- if (((event->irqflags & IRQF_TRIGGER_RISING) && value == 1) ||181181- ((event->irqflags & IRQF_TRIGGER_FALLING) && value == 0))182182- event->handler(event->irq, event);173173+ if (run_edge_events_on_boot &&174174+ (event->irqflags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING))) {175175+ value = gpiod_get_raw_value_cansleep(event->desc);176176+ if (((event->irqflags & IRQF_TRIGGER_RISING) && value == 1) ||177177+ ((event->irqflags & IRQF_TRIGGER_FALLING) && value == 0))178178+ event->handler(event->irq, event);179179+ }183180}184181185182static void acpi_gpiochip_request_irqs(struct acpi_gpio_chip *acpi_gpio)···12921283}12931284/* We must use _sync so that this runs after the first deferred_probe run */12941285late_initcall_sync(acpi_gpio_handle_deferred_request_irqs);12861286+12871287+static const struct dmi_system_id run_edge_events_on_boot_blacklist[] = {12881288+ {12891289+ .matches = {12901290+ DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),12911291+ DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),12921292+ }12931293+ },12941294+ {} /* Terminating entry */12951295+};12961296+12971297+static int acpi_gpio_setup_params(void)12981298+{12991299+ if (run_edge_events_on_boot < 0) {13001300+ if (dmi_check_system(run_edge_events_on_boot_blacklist))13011301+ run_edge_events_on_boot = 0;13021302+ else13031303+ run_edge_events_on_boot = 1;13041304+ }13051305+13061306+ return 0;13071307+}13081308+13091309+/* Directly after dmi_setup() which runs as core_initcall() */13101310+postcore_initcall(acpi_gpio_setup_params);
+9-18
drivers/gpio/gpiolib-of.c
···343343344344 desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,345345 &of_flags);346346- /*347347- * -EPROBE_DEFER in our case means that we found a348348- * valid GPIO property, but no controller has been349349- * registered so far.350350- *351351- * This means we don't need to look any further for352352- * alternate name conventions, and we should really353353- * preserve the return code for our user to be able to354354- * retry probing later.355355- */356356- if (IS_ERR(desc) && PTR_ERR(desc) == -EPROBE_DEFER)357357- return desc;358346359359- if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))347347+ if (!IS_ERR(desc) || PTR_ERR(desc) != -ENOENT)360348 break;361349 }362350363363- /* Special handling for SPI GPIOs if used */364364- if (IS_ERR(desc))351351+ if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {352352+ /* Special handling for SPI GPIOs if used */365353 desc = of_find_spi_gpio(dev, con_id, &of_flags);366366- if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) {354354+ }355355+356356+ if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {367357 /* This quirk looks up flags and all */368358 desc = of_find_spi_cs_gpio(dev, con_id, idx, flags);369359 if (!IS_ERR(desc))370360 return desc;371361 }372362373373- /* Special handling for regulator GPIOs if used */374374- if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)363363+ if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {364364+ /* Special handling for regulator GPIOs if used */375365 desc = of_find_regulator_gpio(dev, con_id, &of_flags);366366+ }376367377368 if (IS_ERR(desc))378369 return desc;
+11-5
drivers/gpio/gpiolib.c
···536536 return -EINVAL;537537538538 /*539539+ * Do not allow both INPUT & OUTPUT flags to be set as they are540540+ * contradictory.541541+ */542542+ if ((lflags & GPIOHANDLE_REQUEST_INPUT) &&543543+ (lflags & GPIOHANDLE_REQUEST_OUTPUT))544544+ return -EINVAL;545545+546546+ /*539547 * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If540548 * the hardware actually supports enabling both at the same time the541549 * electrical result would be disastrous.···934926 }935927936928 /* This is just wrong: we don't look for events on output lines */937937- if (lflags & GPIOHANDLE_REQUEST_OUTPUT) {929929+ if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) ||930930+ (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) ||931931+ (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) {938932 ret = -EINVAL;939933 goto out_free_label;940934 }···950940951941 if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW)952942 set_bit(FLAG_ACTIVE_LOW, &desc->flags);953953- if (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN)954954- set_bit(FLAG_OPEN_DRAIN, &desc->flags);955955- if (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)956956- set_bit(FLAG_OPEN_SOURCE, &desc->flags);957943958944 ret = gpiod_direction_input(desc);959945 if (ret)
+48-6
drivers/gpu/drm/drm_modes.c
···14541454}1455145514561456static int drm_mode_parse_cmdline_extra(const char *str, int length,14571457+ bool freestanding,14571458 const struct drm_connector *connector,14581459 struct drm_cmdline_mode *mode)14591460{···14631462 for (i = 0; i < length; i++) {14641463 switch (str[i]) {14651464 case 'i':14651465+ if (freestanding)14661466+ return -EINVAL;14671467+14661468 mode->interlace = true;14671469 break;14681470 case 'm':14711471+ if (freestanding)14721472+ return -EINVAL;14731473+14691474 mode->margins = true;14701475 break;14711476 case 'D':···15491542 if (extras) {15501543 int ret = drm_mode_parse_cmdline_extra(end_ptr + i,15511544 1,15451545+ false,15521546 connector,15531547 mode);15541548 if (ret)···16771669 return 0;16781670}1679167116721672+static const char * const drm_named_modes_whitelist[] = {16731673+ "NTSC",16741674+ "PAL",16751675+};16761676+16771677+static bool drm_named_mode_is_in_whitelist(const char *mode, unsigned int size)16781678+{16791679+ int i;16801680+16811681+ for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++)16821682+ if (!strncmp(mode, drm_named_modes_whitelist[i], size))16831683+ return true;16841684+16851685+ return false;16861686+}16871687+16801688/**16811689 * drm_mode_parse_command_line_for_connector - parse command line modeline for connector16821690 * @mode_option: optional per connector mode option···17491725 * bunch of things:17501726 * - We need to make sure that the first character (which17511727 * would be our resolution in X) is a digit.17521752- * - However, if the X resolution is missing, then we end up17531753- * with something like x<yres>, with our first character17541754- * being an alpha-numerical character, which would be17551755- * considered a named mode.17281728+ * - If not, then it's either a named mode or a force on/off.17291729+ * To distinguish between the two, we need to run the17301730+ * extra parsing function, and if not, then we consider it17311731+ * a named mode.17561732 *17571733 * If this isn't enough, we should add more heuristics here,17581734 * and matching unit-tests.17591735 */17601760- if (!isdigit(name[0]) && name[0] != 'x')17361736+ if (!isdigit(name[0]) && name[0] != 'x') {17371737+ unsigned int namelen = strlen(name);17381738+17391739+ /*17401740+ * Only the force on/off options can be in that case,17411741+ * and they all take a single character.17421742+ */17431743+ if (namelen == 1) {17441744+ ret = drm_mode_parse_cmdline_extra(name, namelen, true,17451745+ connector, mode);17461746+ if (!ret)17471747+ return true;17481748+ }17491749+17611750 named_mode = true;17511751+ }1762175217631753 /* Try to locate the bpp and refresh specifiers, if any */17641754 bpp_ptr = strchr(name, '-');···18101772 if (named_mode) {18111773 if (mode_end + 1 > DRM_DISPLAY_MODE_LEN)18121774 return false;17751775+17761776+ if (!drm_named_mode_is_in_whitelist(name, mode_end))17771777+ return false;17781778+18131779 strscpy(mode->name, name, mode_end + 1);18141780 } else {18151781 ret = drm_mode_parse_cmdline_res_mode(name, mode_end,···18531811 extra_ptr != options_ptr) {18541812 int len = strlen(name) - (extra_ptr - name);1855181318561856- ret = drm_mode_parse_cmdline_extra(extra_ptr, len,18141814+ ret = drm_mode_parse_cmdline_extra(extra_ptr, len, false,18571815 connector, mode);18581816 if (ret)18591817 return false;
+9-1
drivers/gpu/drm/i915/display/intel_dp_mst.c
···128128 limits.max_lane_count = intel_dp_max_lane_count(intel_dp);129129130130 limits.min_bpp = intel_dp_min_bpp(pipe_config);131131- limits.max_bpp = pipe_config->pipe_bpp;131131+ /*132132+ * FIXME: If all the streams can't fit into the link with133133+ * their current pipe_bpp we should reduce pipe_bpp across134134+ * the board until things start to fit. Until then we135135+ * limit to <= 8bpc since that's what was hardcoded for all136136+ * MST streams previously. This hack should be removed once137137+ * we have the proper retry logic in place.138138+ */139139+ limits.max_bpp = min(pipe_config->pipe_bpp, 24);132140133141 intel_dp_adjust_compliance_config(intel_dp, pipe_config, &limits);134142
+1-9
drivers/gpu/drm/i915/gem/i915_gem_userptr.c
···664664665665 for_each_sgt_page(page, sgt_iter, pages) {666666 if (obj->mm.dirty)667667- /*668668- * As this may not be anonymous memory (e.g. shmem)669669- * but exist on a real mapping, we have to lock670670- * the page in order to dirty it -- holding671671- * the page reference is not sufficient to672672- * prevent the inode from being truncated.673673- * Play safe and take the lock.674674- */675675- set_page_dirty_lock(page);667667+ set_page_dirty(page);676668677669 mark_page_accessed(page);678670 put_page(page);
-5
drivers/gpu/drm/i915/gt/intel_workarounds.c
···308308 FLOW_CONTROL_ENABLE |309309 PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE);310310311311- /* Syncing dependencies between camera and graphics:skl,bxt,kbl */312312- if (!IS_COFFEELAKE(i915))313313- WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3,314314- GEN9_DISABLE_OCL_OOB_SUPPRESS_LOGIC);315315-316311 /* WaEnableYV12BugFixInHalfSliceChicken7:skl,bxt,kbl,glk,cfl */317312 /* WaEnableSamplerGPGPUPreemptionSupport:skl,bxt,kbl,cfl */318313 WA_SET_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN7,
···774774 /* All SDHI have SDIO status bits which must be 1 */775775 mmc_data->flags |= TMIO_MMC_SDIO_STATUS_SETBITS;776776777777- pm_runtime_enable(&pdev->dev);778778-779777 ret = renesas_sdhi_clk_enable(host);780778 if (ret)781779 goto efree;···854856efree:855857 tmio_mmc_host_free(host);856858857857- pm_runtime_disable(&pdev->dev);858858-859859 return ret;860860}861861EXPORT_SYMBOL_GPL(renesas_sdhi_probe);···864868865869 tmio_mmc_host_remove(host);866870 renesas_sdhi_clk_disable(host);867867-868868- pm_runtime_disable(&pdev->dev);869871870872 return 0;871873}
···787787}788788789789static int tun_attach(struct tun_struct *tun, struct file *file,790790- bool skip_filter, bool napi, bool napi_frags)790790+ bool skip_filter, bool napi, bool napi_frags,791791+ bool publish_tun)791792{792793 struct tun_file *tfile = file->private_data;793794 struct net_device *dev = tun->dev;···871870 * initialized tfile; otherwise we risk using half-initialized872871 * object.873872 */874874- rcu_assign_pointer(tfile->tun, tun);873873+ if (publish_tun)874874+ rcu_assign_pointer(tfile->tun, tun);875875 rcu_assign_pointer(tun->tfiles[tun->numqueues], tfile);876876 tun->numqueues++;877877 tun_set_real_num_queues(tun);···2732273027332731 err = tun_attach(tun, file, ifr->ifr_flags & IFF_NOFILTER,27342732 ifr->ifr_flags & IFF_NAPI,27352735- ifr->ifr_flags & IFF_NAPI_FRAGS);27332733+ ifr->ifr_flags & IFF_NAPI_FRAGS, true);27362734 if (err < 0)27372735 return err;27382736···2831282928322830 INIT_LIST_HEAD(&tun->disabled);28332831 err = tun_attach(tun, file, false, ifr->ifr_flags & IFF_NAPI,28342834- ifr->ifr_flags & IFF_NAPI_FRAGS);28322832+ ifr->ifr_flags & IFF_NAPI_FRAGS, false);28352833 if (err < 0)28362834 goto err_free_flow;2837283528382836 err = register_netdevice(tun->dev);28392837 if (err < 0)28402838 goto err_detach;28392839+ /* free_netdev() won't check refcnt, to aovid race28402840+ * with dev_put() we need publish tun after registration.28412841+ */28422842+ rcu_assign_pointer(tfile->tun, tun);28412843 }2842284428432845 netif_carrier_on(tun->dev);···29842978 if (ret < 0)29852979 goto unlock;29862980 ret = tun_attach(tun, file, false, tun->flags & IFF_NAPI,29872987- tun->flags & IFF_NAPI_FRAGS);29812981+ tun->flags & IFF_NAPI_FRAGS, true);29882982 } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) {29892983 tun = rtnl_dereference(tfile->tun);29902984 if (!tun || !(tun->flags & IFF_MULTI_QUEUE) || tfile->detached)
+9-1
drivers/net/usb/cdc_ether.c
···206206 goto bad_desc;207207 }208208skip:209209- if (rndis && header.usb_cdc_acm_descriptor &&209209+ /* Communcation class functions with bmCapabilities are not210210+ * RNDIS. But some Wireless class RNDIS functions use211211+ * bmCapabilities for their own purpose. The failsafe is212212+ * therefore applied only to Communication class RNDIS213213+ * functions. The rndis test is redundant, but a cheap214214+ * optimization.215215+ */216216+ if (rndis && is_rndis(&intf->cur_altsetting->desc) &&217217+ header.usb_cdc_acm_descriptor &&210218 header.usb_cdc_acm_descriptor->bmCapabilities) {211219 dev_dbg(&intf->dev,212220 "ACM capabilities %02x, not really RNDIS?\n",
+1-1
drivers/net/virtio_net.c
···13311331 }13321332 }1333133313341334- if (rq->vq->num_free > virtqueue_get_vring_size(rq->vq) / 2) {13341334+ if (rq->vq->num_free > min((unsigned int)budget, virtqueue_get_vring_size(rq->vq)) / 2) {13351335 if (!try_fill_recv(vi, rq, GFP_ATOMIC))13361336 schedule_delayed_work(&vi->refill, 0);13371337 }
···25522552 if (IS_ERR(map))25532553 return map;25542554 } else25552555- map = ERR_PTR(-ENODEV);25552555+ return ERR_PTR(-ENODEV);2556255625572557 ctx->maps[ASPEED_IP_LPC] = map;25582558 dev_dbg(ctx->dev, "Acquired LPC regmap");···25602560 }2561256125622562 return ERR_PTR(-EINVAL);25632563+}25642564+25652565+static int aspeed_g5_sig_expr_eval(struct aspeed_pinmux_data *ctx,25662566+ const struct aspeed_sig_expr *expr,25672567+ bool enabled)25682568+{25692569+ int ret;25702570+ int i;25712571+25722572+ for (i = 0; i < expr->ndescs; i++) {25732573+ const struct aspeed_sig_desc *desc = &expr->descs[i];25742574+ struct regmap *map;25752575+25762576+ map = aspeed_g5_acquire_regmap(ctx, desc->ip);25772577+ if (IS_ERR(map)) {25782578+ dev_err(ctx->dev,25792579+ "Failed to acquire regmap for IP block %d\n",25802580+ desc->ip);25812581+ return PTR_ERR(map);25822582+ }25832583+25842584+ ret = aspeed_sig_desc_eval(desc, enabled, ctx->maps[desc->ip]);25852585+ if (ret <= 0)25862586+ return ret;25872587+ }25882588+25892589+ return 1;25632590}2564259125652592/**···26742647}2675264826762649static const struct aspeed_pinmux_ops aspeed_g5_ops = {26502650+ .eval = aspeed_g5_sig_expr_eval,26772651 .set = aspeed_g5_sig_expr_set,26782652};26792653
+5-2
drivers/pinctrl/aspeed/pinmux-aspeed.c
···7878 * neither the enabled nor disabled state. Thus we must explicitly test for7979 * either condition as required.8080 */8181-int aspeed_sig_expr_eval(const struct aspeed_pinmux_data *ctx,8181+int aspeed_sig_expr_eval(struct aspeed_pinmux_data *ctx,8282 const struct aspeed_sig_expr *expr, bool enabled)8383{8484- int i;8584 int ret;8585+ int i;8686+8787+ if (ctx->ops->eval)8888+ return ctx->ops->eval(ctx, expr, enabled);86898790 for (i = 0; i < expr->ndescs; i++) {8891 const struct aspeed_sig_desc *desc = &expr->descs[i];
···57155715 * 0 = Set nr_hw_queues by the number of CPUs or HW queues.57165716 * 1,128 = Manually specify the maximum nr_hw_queue value to be set,57175717 *57185718- * Value range is [0,128]. Default value is 8.57185718+ * Value range is [0,256]. Default value is 8.57195719 */57205720LPFC_ATTR_R(fcp_mq_threshold, LPFC_FCP_MQ_THRESHOLD_DEF,57215721 LPFC_FCP_MQ_THRESHOLD_MIN, LPFC_FCP_MQ_THRESHOLD_MAX,
+1-1
drivers/scsi/lpfc/lpfc_sli4.h
···46464747/* FCP MQ queue count limiting */4848#define LPFC_FCP_MQ_THRESHOLD_MIN 04949-#define LPFC_FCP_MQ_THRESHOLD_MAX 1284949+#define LPFC_FCP_MQ_THRESHOLD_MAX 2565050#define LPFC_FCP_MQ_THRESHOLD_DEF 851515252/* Common buffer size to accomidate SCSI and NVME IO buffers */
···2222 * Using this limit prevents one virtqueue from starving others. */2323#define VHOST_TEST_WEIGHT 0x8000024242525+/* Max number of packets transferred before requeueing the job.2626+ * Using this limit prevents one virtqueue from starving others with2727+ * pkts.2828+ */2929+#define VHOST_TEST_PKT_WEIGHT 2563030+2531enum {2632 VHOST_TEST_VQ = 0,2733 VHOST_TEST_VQ_MAX = 1,···8680 }8781 vhost_add_used_and_signal(&n->dev, vq, head, 0);8882 total_len += len;8989- if (unlikely(total_len >= VHOST_TEST_WEIGHT)) {9090- vhost_poll_queue(&vq->poll);8383+ if (unlikely(vhost_exceeds_weight(vq, 0, total_len)))9184 break;9292- }9385 }94869587 mutex_unlock(&vq->mutex);···119115 dev = &n->dev;120116 vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];121117 n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick;122122- vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);118118+ vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX, UIO_MAXIOV,119119+ VHOST_TEST_PKT_WEIGHT, VHOST_TEST_WEIGHT);123120124121 f->private_data = n;125122
+7-517
drivers/vhost/vhost.c
···203203int vhost_poll_start(struct vhost_poll *poll, struct file *file)204204{205205 __poll_t mask;206206- int ret = 0;207206208207 if (poll->wqh)209208 return 0;···212213 vhost_poll_wakeup(&poll->wait, 0, 0, poll_to_key(mask));213214 if (mask & EPOLLERR) {214215 vhost_poll_stop(poll);215215- ret = -EINVAL;216216+ return -EINVAL;216217 }217218218218- return ret;219219+ return 0;219220}220221EXPORT_SYMBOL_GPL(vhost_poll_start);221222···297298 __vhost_vq_meta_reset(d->vqs[i]);298299}299300300300-#if VHOST_ARCH_CAN_ACCEL_UACCESS301301-static void vhost_map_unprefetch(struct vhost_map *map)302302-{303303- kfree(map->pages);304304- map->pages = NULL;305305- map->npages = 0;306306- map->addr = NULL;307307-}308308-309309-static void vhost_uninit_vq_maps(struct vhost_virtqueue *vq)310310-{311311- struct vhost_map *map[VHOST_NUM_ADDRS];312312- int i;313313-314314- spin_lock(&vq->mmu_lock);315315- for (i = 0; i < VHOST_NUM_ADDRS; i++) {316316- map[i] = rcu_dereference_protected(vq->maps[i],317317- lockdep_is_held(&vq->mmu_lock));318318- if (map[i])319319- rcu_assign_pointer(vq->maps[i], NULL);320320- }321321- spin_unlock(&vq->mmu_lock);322322-323323- synchronize_rcu();324324-325325- for (i = 0; i < VHOST_NUM_ADDRS; i++)326326- if (map[i])327327- vhost_map_unprefetch(map[i]);328328-329329-}330330-331331-static void vhost_reset_vq_maps(struct vhost_virtqueue *vq)332332-{333333- int i;334334-335335- vhost_uninit_vq_maps(vq);336336- for (i = 0; i < VHOST_NUM_ADDRS; i++)337337- vq->uaddrs[i].size = 0;338338-}339339-340340-static bool vhost_map_range_overlap(struct vhost_uaddr *uaddr,341341- unsigned long start,342342- unsigned long end)343343-{344344- if (unlikely(!uaddr->size))345345- return false;346346-347347- return !(end < uaddr->uaddr || start > uaddr->uaddr - 1 + uaddr->size);348348-}349349-350350-static void vhost_invalidate_vq_start(struct vhost_virtqueue *vq,351351- int index,352352- unsigned long start,353353- unsigned long end)354354-{355355- struct vhost_uaddr *uaddr = &vq->uaddrs[index];356356- struct vhost_map *map;357357- int i;358358-359359- if (!vhost_map_range_overlap(uaddr, start, end))360360- return;361361-362362- spin_lock(&vq->mmu_lock);363363- ++vq->invalidate_count;364364-365365- map = rcu_dereference_protected(vq->maps[index],366366- lockdep_is_held(&vq->mmu_lock));367367- if (map) {368368- if (uaddr->write) {369369- for (i = 0; i < map->npages; i++)370370- set_page_dirty(map->pages[i]);371371- }372372- rcu_assign_pointer(vq->maps[index], NULL);373373- }374374- spin_unlock(&vq->mmu_lock);375375-376376- if (map) {377377- synchronize_rcu();378378- vhost_map_unprefetch(map);379379- }380380-}381381-382382-static void vhost_invalidate_vq_end(struct vhost_virtqueue *vq,383383- int index,384384- unsigned long start,385385- unsigned long end)386386-{387387- if (!vhost_map_range_overlap(&vq->uaddrs[index], start, end))388388- return;389389-390390- spin_lock(&vq->mmu_lock);391391- --vq->invalidate_count;392392- spin_unlock(&vq->mmu_lock);393393-}394394-395395-static int vhost_invalidate_range_start(struct mmu_notifier *mn,396396- const struct mmu_notifier_range *range)397397-{398398- struct vhost_dev *dev = container_of(mn, struct vhost_dev,399399- mmu_notifier);400400- int i, j;401401-402402- if (!mmu_notifier_range_blockable(range))403403- return -EAGAIN;404404-405405- for (i = 0; i < dev->nvqs; i++) {406406- struct vhost_virtqueue *vq = dev->vqs[i];407407-408408- for (j = 0; j < VHOST_NUM_ADDRS; j++)409409- vhost_invalidate_vq_start(vq, j,410410- range->start,411411- range->end);412412- }413413-414414- return 0;415415-}416416-417417-static void vhost_invalidate_range_end(struct mmu_notifier *mn,418418- const struct mmu_notifier_range *range)419419-{420420- struct vhost_dev *dev = container_of(mn, struct vhost_dev,421421- mmu_notifier);422422- int i, j;423423-424424- for (i = 0; i < dev->nvqs; i++) {425425- struct vhost_virtqueue *vq = dev->vqs[i];426426-427427- for (j = 0; j < VHOST_NUM_ADDRS; j++)428428- vhost_invalidate_vq_end(vq, j,429429- range->start,430430- range->end);431431- }432432-}433433-434434-static const struct mmu_notifier_ops vhost_mmu_notifier_ops = {435435- .invalidate_range_start = vhost_invalidate_range_start,436436- .invalidate_range_end = vhost_invalidate_range_end,437437-};438438-439439-static void vhost_init_maps(struct vhost_dev *dev)440440-{441441- struct vhost_virtqueue *vq;442442- int i, j;443443-444444- dev->mmu_notifier.ops = &vhost_mmu_notifier_ops;445445-446446- for (i = 0; i < dev->nvqs; ++i) {447447- vq = dev->vqs[i];448448- for (j = 0; j < VHOST_NUM_ADDRS; j++)449449- RCU_INIT_POINTER(vq->maps[j], NULL);450450- }451451-}452452-#endif453453-454301static void vhost_vq_reset(struct vhost_dev *dev,455302 struct vhost_virtqueue *vq)456303{···325480 vq->busyloop_timeout = 0;326481 vq->umem = NULL;327482 vq->iotlb = NULL;328328- vq->invalidate_count = 0;329483 __vhost_vq_meta_reset(vq);330330-#if VHOST_ARCH_CAN_ACCEL_UACCESS331331- vhost_reset_vq_maps(vq);332332-#endif333484}334485335486static int vhost_worker(void *data)···475634 INIT_LIST_HEAD(&dev->read_list);476635 INIT_LIST_HEAD(&dev->pending_list);477636 spin_lock_init(&dev->iotlb_lock);478478-#if VHOST_ARCH_CAN_ACCEL_UACCESS479479- vhost_init_maps(dev);480480-#endif637637+481638482639 for (i = 0; i < dev->nvqs; ++i) {483640 vq = dev->vqs[i];···484645 vq->heads = NULL;485646 vq->dev = dev;486647 mutex_init(&vq->mutex);487487- spin_lock_init(&vq->mmu_lock);488648 vhost_vq_reset(dev, vq);489649 if (vq->handle_kick)490650 vhost_poll_init(&vq->poll, vq->handle_kick,···563725 if (err)564726 goto err_cgroup;565727566566-#if VHOST_ARCH_CAN_ACCEL_UACCESS567567- err = mmu_notifier_register(&dev->mmu_notifier, dev->mm);568568- if (err)569569- goto err_mmu_notifier;570570-#endif571571-572728 return 0;573573-574574-#if VHOST_ARCH_CAN_ACCEL_UACCESS575575-err_mmu_notifier:576576- vhost_dev_free_iovecs(dev);577577-#endif578729err_cgroup:579730 kthread_stop(worker);580731 dev->worker = NULL;···654827 spin_unlock(&dev->iotlb_lock);655828}656829657657-#if VHOST_ARCH_CAN_ACCEL_UACCESS658658-static void vhost_setup_uaddr(struct vhost_virtqueue *vq,659659- int index, unsigned long uaddr,660660- size_t size, bool write)661661-{662662- struct vhost_uaddr *addr = &vq->uaddrs[index];663663-664664- addr->uaddr = uaddr;665665- addr->size = size;666666- addr->write = write;667667-}668668-669669-static void vhost_setup_vq_uaddr(struct vhost_virtqueue *vq)670670-{671671- vhost_setup_uaddr(vq, VHOST_ADDR_DESC,672672- (unsigned long)vq->desc,673673- vhost_get_desc_size(vq, vq->num),674674- false);675675- vhost_setup_uaddr(vq, VHOST_ADDR_AVAIL,676676- (unsigned long)vq->avail,677677- vhost_get_avail_size(vq, vq->num),678678- false);679679- vhost_setup_uaddr(vq, VHOST_ADDR_USED,680680- (unsigned long)vq->used,681681- vhost_get_used_size(vq, vq->num),682682- true);683683-}684684-685685-static int vhost_map_prefetch(struct vhost_virtqueue *vq,686686- int index)687687-{688688- struct vhost_map *map;689689- struct vhost_uaddr *uaddr = &vq->uaddrs[index];690690- struct page **pages;691691- int npages = DIV_ROUND_UP(uaddr->size, PAGE_SIZE);692692- int npinned;693693- void *vaddr, *v;694694- int err;695695- int i;696696-697697- spin_lock(&vq->mmu_lock);698698-699699- err = -EFAULT;700700- if (vq->invalidate_count)701701- goto err;702702-703703- err = -ENOMEM;704704- map = kmalloc(sizeof(*map), GFP_ATOMIC);705705- if (!map)706706- goto err;707707-708708- pages = kmalloc_array(npages, sizeof(struct page *), GFP_ATOMIC);709709- if (!pages)710710- goto err_pages;711711-712712- err = EFAULT;713713- npinned = __get_user_pages_fast(uaddr->uaddr, npages,714714- uaddr->write, pages);715715- if (npinned > 0)716716- release_pages(pages, npinned);717717- if (npinned != npages)718718- goto err_gup;719719-720720- for (i = 0; i < npinned; i++)721721- if (PageHighMem(pages[i]))722722- goto err_gup;723723-724724- vaddr = v = page_address(pages[0]);725725-726726- /* For simplicity, fallback to userspace address if VA is not727727- * contigious.728728- */729729- for (i = 1; i < npinned; i++) {730730- v += PAGE_SIZE;731731- if (v != page_address(pages[i]))732732- goto err_gup;733733- }734734-735735- map->addr = vaddr + (uaddr->uaddr & (PAGE_SIZE - 1));736736- map->npages = npages;737737- map->pages = pages;738738-739739- rcu_assign_pointer(vq->maps[index], map);740740- /* No need for a synchronize_rcu(). This function should be741741- * called by dev->worker so we are serialized with all742742- * readers.743743- */744744- spin_unlock(&vq->mmu_lock);745745-746746- return 0;747747-748748-err_gup:749749- kfree(pages);750750-err_pages:751751- kfree(map);752752-err:753753- spin_unlock(&vq->mmu_lock);754754- return err;755755-}756756-#endif757757-758830void vhost_dev_cleanup(struct vhost_dev *dev)759831{760832 int i;···683957 kthread_stop(dev->worker);684958 dev->worker = NULL;685959 }686686- if (dev->mm) {687687-#if VHOST_ARCH_CAN_ACCEL_UACCESS688688- mmu_notifier_unregister(&dev->mmu_notifier, dev->mm);689689-#endif960960+ if (dev->mm)690961 mmput(dev->mm);691691- }692692-#if VHOST_ARCH_CAN_ACCEL_UACCESS693693- for (i = 0; i < dev->nvqs; i++)694694- vhost_uninit_vq_maps(dev->vqs[i]);695695-#endif696962 dev->mm = NULL;697963}698964EXPORT_SYMBOL_GPL(vhost_dev_cleanup);···91311959141196static inline int vhost_put_avail_event(struct vhost_virtqueue *vq)9151197{916916-#if VHOST_ARCH_CAN_ACCEL_UACCESS917917- struct vhost_map *map;918918- struct vring_used *used;919919-920920- if (!vq->iotlb) {921921- rcu_read_lock();922922-923923- map = rcu_dereference(vq->maps[VHOST_ADDR_USED]);924924- if (likely(map)) {925925- used = map->addr;926926- *((__virtio16 *)&used->ring[vq->num]) =927927- cpu_to_vhost16(vq, vq->avail_idx);928928- rcu_read_unlock();929929- return 0;930930- }931931-932932- rcu_read_unlock();933933- }934934-#endif935935-9361198 return vhost_put_user(vq, cpu_to_vhost16(vq, vq->avail_idx),9371199 vhost_avail_event(vq));9381200}···9211223 struct vring_used_elem *head, int idx,9221224 int count)9231225{924924-#if VHOST_ARCH_CAN_ACCEL_UACCESS925925- struct vhost_map *map;926926- struct vring_used *used;927927- size_t size;928928-929929- if (!vq->iotlb) {930930- rcu_read_lock();931931-932932- map = rcu_dereference(vq->maps[VHOST_ADDR_USED]);933933- if (likely(map)) {934934- used = map->addr;935935- size = count * sizeof(*head);936936- memcpy(used->ring + idx, head, size);937937- rcu_read_unlock();938938- return 0;939939- }940940-941941- rcu_read_unlock();942942- }943943-#endif944944-9451226 return vhost_copy_to_user(vq, vq->used->ring + idx, head,9461227 count * sizeof(*head));9471228}···9281251static inline int vhost_put_used_flags(struct vhost_virtqueue *vq)92912529301253{931931-#if VHOST_ARCH_CAN_ACCEL_UACCESS932932- struct vhost_map *map;933933- struct vring_used *used;934934-935935- if (!vq->iotlb) {936936- rcu_read_lock();937937-938938- map = rcu_dereference(vq->maps[VHOST_ADDR_USED]);939939- if (likely(map)) {940940- used = map->addr;941941- used->flags = cpu_to_vhost16(vq, vq->used_flags);942942- rcu_read_unlock();943943- return 0;944944- }945945-946946- rcu_read_unlock();947947- }948948-#endif949949-9501254 return vhost_put_user(vq, cpu_to_vhost16(vq, vq->used_flags),9511255 &vq->used->flags);9521256}···9351277static inline int vhost_put_used_idx(struct vhost_virtqueue *vq)93612789371279{938938-#if VHOST_ARCH_CAN_ACCEL_UACCESS939939- struct vhost_map *map;940940- struct vring_used *used;941941-942942- if (!vq->iotlb) {943943- rcu_read_lock();944944-945945- map = rcu_dereference(vq->maps[VHOST_ADDR_USED]);946946- if (likely(map)) {947947- used = map->addr;948948- used->idx = cpu_to_vhost16(vq, vq->last_used_idx);949949- rcu_read_unlock();950950- return 0;951951- }952952-953953- rcu_read_unlock();954954- }955955-#endif956956-9571280 return vhost_put_user(vq, cpu_to_vhost16(vq, vq->last_used_idx),9581281 &vq->used->idx);9591282}···9801341static inline int vhost_get_avail_idx(struct vhost_virtqueue *vq,9811342 __virtio16 *idx)9821343{983983-#if VHOST_ARCH_CAN_ACCEL_UACCESS984984- struct vhost_map *map;985985- struct vring_avail *avail;986986-987987- if (!vq->iotlb) {988988- rcu_read_lock();989989-990990- map = rcu_dereference(vq->maps[VHOST_ADDR_AVAIL]);991991- if (likely(map)) {992992- avail = map->addr;993993- *idx = avail->idx;994994- rcu_read_unlock();995995- return 0;996996- }997997-998998- rcu_read_unlock();999999- }10001000-#endif10011001-10021344 return vhost_get_avail(vq, *idx, &vq->avail->idx);10031345}1004134610051347static inline int vhost_get_avail_head(struct vhost_virtqueue *vq,10061348 __virtio16 *head, int idx)10071349{10081008-#if VHOST_ARCH_CAN_ACCEL_UACCESS10091009- struct vhost_map *map;10101010- struct vring_avail *avail;10111011-10121012- if (!vq->iotlb) {10131013- rcu_read_lock();10141014-10151015- map = rcu_dereference(vq->maps[VHOST_ADDR_AVAIL]);10161016- if (likely(map)) {10171017- avail = map->addr;10181018- *head = avail->ring[idx & (vq->num - 1)];10191019- rcu_read_unlock();10201020- return 0;10211021- }10221022-10231023- rcu_read_unlock();10241024- }10251025-#endif10261026-10271350 return vhost_get_avail(vq, *head,10281351 &vq->avail->ring[idx & (vq->num - 1)]);10291352}···9931392static inline int vhost_get_avail_flags(struct vhost_virtqueue *vq,9941393 __virtio16 *flags)9951394{996996-#if VHOST_ARCH_CAN_ACCEL_UACCESS997997- struct vhost_map *map;998998- struct vring_avail *avail;999999-10001000- if (!vq->iotlb) {10011001- rcu_read_lock();10021002-10031003- map = rcu_dereference(vq->maps[VHOST_ADDR_AVAIL]);10041004- if (likely(map)) {10051005- avail = map->addr;10061006- *flags = avail->flags;10071007- rcu_read_unlock();10081008- return 0;10091009- }10101010-10111011- rcu_read_unlock();10121012- }10131013-#endif10141014-10151395 return vhost_get_avail(vq, *flags, &vq->avail->flags);10161396}1017139710181398static inline int vhost_get_used_event(struct vhost_virtqueue *vq,10191399 __virtio16 *event)10201400{10211021-#if VHOST_ARCH_CAN_ACCEL_UACCESS10221022- struct vhost_map *map;10231023- struct vring_avail *avail;10241024-10251025- if (!vq->iotlb) {10261026- rcu_read_lock();10271027- map = rcu_dereference(vq->maps[VHOST_ADDR_AVAIL]);10281028- if (likely(map)) {10291029- avail = map->addr;10301030- *event = (__virtio16)avail->ring[vq->num];10311031- rcu_read_unlock();10321032- return 0;10331033- }10341034- rcu_read_unlock();10351035- }10361036-#endif10371037-10381401 return vhost_get_avail(vq, *event, vhost_used_event(vq));10391402}1040140310411404static inline int vhost_get_used_idx(struct vhost_virtqueue *vq,10421405 __virtio16 *idx)10431406{10441044-#if VHOST_ARCH_CAN_ACCEL_UACCESS10451045- struct vhost_map *map;10461046- struct vring_used *used;10471047-10481048- if (!vq->iotlb) {10491049- rcu_read_lock();10501050-10511051- map = rcu_dereference(vq->maps[VHOST_ADDR_USED]);10521052- if (likely(map)) {10531053- used = map->addr;10541054- *idx = used->idx;10551055- rcu_read_unlock();10561056- return 0;10571057- }10581058-10591059- rcu_read_unlock();10601060- }10611061-#endif10621062-10631407 return vhost_get_used(vq, *idx, &vq->used->idx);10641408}1065140910661410static inline int vhost_get_desc(struct vhost_virtqueue *vq,10671411 struct vring_desc *desc, int idx)10681412{10691069-#if VHOST_ARCH_CAN_ACCEL_UACCESS10701070- struct vhost_map *map;10711071- struct vring_desc *d;10721072-10731073- if (!vq->iotlb) {10741074- rcu_read_lock();10751075-10761076- map = rcu_dereference(vq->maps[VHOST_ADDR_DESC]);10771077- if (likely(map)) {10781078- d = map->addr;10791079- *desc = *(d + idx);10801080- rcu_read_unlock();10811081- return 0;10821082- }10831083-10841084- rcu_read_unlock();10851085- }10861086-#endif10871087-10881413 return vhost_copy_from_user(vq, desc, vq->desc + idx, sizeof(*desc));10891414}10901415···13511824 return true;13521825}1353182613541354-#if VHOST_ARCH_CAN_ACCEL_UACCESS13551355-static void vhost_vq_map_prefetch(struct vhost_virtqueue *vq)13561356-{13571357- struct vhost_map __rcu *map;13581358- int i;13591359-13601360- for (i = 0; i < VHOST_NUM_ADDRS; i++) {13611361- rcu_read_lock();13621362- map = rcu_dereference(vq->maps[i]);13631363- rcu_read_unlock();13641364- if (unlikely(!map))13651365- vhost_map_prefetch(vq, i);13661366- }13671367-}13681368-#endif13691369-13701827int vq_meta_prefetch(struct vhost_virtqueue *vq)13711828{13721829 unsigned int num = vq->num;1373183013741374- if (!vq->iotlb) {13751375-#if VHOST_ARCH_CAN_ACCEL_UACCESS13761376- vhost_vq_map_prefetch(vq);13771377-#endif18311831+ if (!vq->iotlb)13781832 return 1;13791379- }1380183313811834 return iotlb_access_ok(vq, VHOST_ACCESS_RO, (u64)(uintptr_t)vq->desc,13821835 vhost_get_desc_size(vq, num), VHOST_ADDR_DESC) &&···1567206015682061 mutex_lock(&vq->mutex);1569206215701570-#if VHOST_ARCH_CAN_ACCEL_UACCESS15711571- /* Unregister MMU notifer to allow invalidation callback15721572- * can access vq->uaddrs[] without holding a lock.15731573- */15741574- if (d->mm)15751575- mmu_notifier_unregister(&d->mmu_notifier, d->mm);15761576-15771577- vhost_uninit_vq_maps(vq);15781578-#endif15791579-15802063 switch (ioctl) {15812064 case VHOST_SET_VRING_NUM:15822065 r = vhost_vring_set_num(d, vq, argp);···15772080 default:15782081 BUG();15792082 }15801580-15811581-#if VHOST_ARCH_CAN_ACCEL_UACCESS15821582- vhost_setup_vq_uaddr(vq);15831583-15841584- if (d->mm)15851585- mmu_notifier_register(&d->mmu_notifier, d->mm);15861586-#endif1587208315882084 mutex_unlock(&vq->mutex);15892085···21782688 /* If this is an input descriptor, increment that count. */21792689 if (access == VHOST_ACCESS_WO) {21802690 *in_num += ret;21812181- if (unlikely(log)) {26912691+ if (unlikely(log && ret)) {21822692 log[*log_num].addr = vhost64_to_cpu(vq, desc.addr);21832693 log[*log_num].len = vhost32_to_cpu(vq, desc.len);21842694 ++*log_num;···23192829 /* If this is an input descriptor,23202830 * increment that count. */23212831 *in_num += ret;23222322- if (unlikely(log)) {28322832+ if (unlikely(log && ret)) {23232833 log[*log_num].addr = vhost64_to_cpu(vq, desc.addr);23242834 log[*log_num].len = vhost32_to_cpu(vq, desc.len);23252835 ++*log_num;
-41
drivers/vhost/vhost.h
···1212#include <linux/virtio_config.h>1313#include <linux/virtio_ring.h>1414#include <linux/atomic.h>1515-#include <linux/pagemap.h>1616-#include <linux/mmu_notifier.h>1717-#include <asm/cacheflush.h>18151916struct vhost_work;2017typedef void (*vhost_work_fn_t)(struct vhost_work *work);···8083 VHOST_NUM_ADDRS = 3,8184};82858383-struct vhost_map {8484- int npages;8585- void *addr;8686- struct page **pages;8787-};8888-8989-struct vhost_uaddr {9090- unsigned long uaddr;9191- size_t size;9292- bool write;9393-};9494-9595-#if defined(CONFIG_MMU_NOTIFIER) && ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 09696-#define VHOST_ARCH_CAN_ACCEL_UACCESS 09797-#else9898-#define VHOST_ARCH_CAN_ACCEL_UACCESS 09999-#endif100100-10186/* The virtqueue structure describes a queue attached to a device. */10287struct vhost_virtqueue {10388 struct vhost_dev *dev;···90111 struct vring_desc __user *desc;91112 struct vring_avail __user *avail;92113 struct vring_used __user *used;9393-9494-#if VHOST_ARCH_CAN_ACCEL_UACCESS9595- /* Read by memory accessors, modified by meta data9696- * prefetching, MMU notifier and vring ioctl().9797- * Synchonrized through mmu_lock (writers) and RCU (writers9898- * and readers).9999- */100100- struct vhost_map __rcu *maps[VHOST_NUM_ADDRS];101101- /* Read by MMU notifier, modified by vring ioctl(),102102- * synchronized through MMU notifier103103- * registering/unregistering.104104- */105105- struct vhost_uaddr uaddrs[VHOST_NUM_ADDRS];106106-#endif107114 const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS];108108-109115 struct file *kick;110116 struct eventfd_ctx *call_ctx;111117 struct eventfd_ctx *error_ctx;···145181 bool user_be;146182#endif147183 u32 busyloop_timeout;148148- spinlock_t mmu_lock;149149- int invalidate_count;150184};151185152186struct vhost_msg_node {···158196159197struct vhost_dev {160198 struct mm_struct *mm;161161-#ifdef CONFIG_MMU_NOTIFIER162162- struct mmu_notifier mmu_notifier;163163-#endif164199 struct mutex mutex;165200 struct vhost_virtqueue **vqs;166201 int nvqs;
+6-2
drivers/virtio/virtio_ring.c
···566566567567unmap_release:568568 err_idx = i;569569- i = head;569569+570570+ if (indirect)571571+ i = 0;572572+ else573573+ i = head;570574571575 for (n = 0; n < total_sg; n++) {572576 if (i == err_idx)573577 break;574578 vring_unmap_one_split(vq, &desc[i]);575575- i = virtio16_to_cpu(_vq->vdev, vq->split.vring.desc[i].next);579579+ i = virtio16_to_cpu(_vq->vdev, desc[i].next);576580 }577581578582 if (indirect)
+26-9
fs/btrfs/extent_io.c
···36283628 TASK_UNINTERRUPTIBLE);36293629}3630363036313631+static void end_extent_buffer_writeback(struct extent_buffer *eb)36323632+{36333633+ clear_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags);36343634+ smp_mb__after_atomic();36353635+ wake_up_bit(&eb->bflags, EXTENT_BUFFER_WRITEBACK);36363636+}36373637+36313638/*36323639 * Lock eb pages and flush the bio if we can't the locks36333640 *···3706369937073700 if (!trylock_page(p)) {37083701 if (!flush) {37093709- ret = flush_write_bio(epd);37103710- if (ret < 0) {37023702+ int err;37033703+37043704+ err = flush_write_bio(epd);37053705+ if (err < 0) {37063706+ ret = err;37113707 failed_page_nr = i;37123708 goto err_unlock;37133709 }···37253715 /* Unlock already locked pages */37263716 for (i = 0; i < failed_page_nr; i++)37273717 unlock_page(eb->pages[i]);37183718+ /*37193719+ * Clear EXTENT_BUFFER_WRITEBACK and wake up anyone waiting on it.37203720+ * Also set back EXTENT_BUFFER_DIRTY so future attempts to this eb can37213721+ * be made and undo everything done before.37223722+ */37233723+ btrfs_tree_lock(eb);37243724+ spin_lock(&eb->refs_lock);37253725+ set_bit(EXTENT_BUFFER_DIRTY, &eb->bflags);37263726+ end_extent_buffer_writeback(eb);37273727+ spin_unlock(&eb->refs_lock);37283728+ percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, eb->len,37293729+ fs_info->dirty_metadata_batch);37303730+ btrfs_clear_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN);37313731+ btrfs_tree_unlock(eb);37283732 return ret;37293729-}37303730-37313731-static void end_extent_buffer_writeback(struct extent_buffer *eb)37323732-{37333733- clear_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags);37343734- smp_mb__after_atomic();37353735- wake_up_bit(&eb->bflags, EXTENT_BUFFER_WRITEBACK);37363733}3737373437383735static void set_btree_ioerr(struct page *page)
···151151152152#endif /* CONFIG_LOCKDEP */153153154154+static struct configfs_fragment *new_fragment(void)155155+{156156+ struct configfs_fragment *p;157157+158158+ p = kmalloc(sizeof(struct configfs_fragment), GFP_KERNEL);159159+ if (p) {160160+ atomic_set(&p->frag_count, 1);161161+ init_rwsem(&p->frag_sem);162162+ p->frag_dead = false;163163+ }164164+ return p;165165+}166166+167167+void put_fragment(struct configfs_fragment *frag)168168+{169169+ if (frag && atomic_dec_and_test(&frag->frag_count))170170+ kfree(frag);171171+}172172+173173+struct configfs_fragment *get_fragment(struct configfs_fragment *frag)174174+{175175+ if (likely(frag))176176+ atomic_inc(&frag->frag_count);177177+ return frag;178178+}179179+154180/*155181 * Allocates a new configfs_dirent and links it to the parent configfs_dirent156182 */157183static struct configfs_dirent *configfs_new_dirent(struct configfs_dirent *parent_sd,158158- void *element, int type)184184+ void *element, int type,185185+ struct configfs_fragment *frag)159186{160187 struct configfs_dirent * sd;161188···202175 kmem_cache_free(configfs_dir_cachep, sd);203176 return ERR_PTR(-ENOENT);204177 }178178+ sd->s_frag = get_fragment(frag);205179 list_add(&sd->s_sibling, &parent_sd->s_children);206180 spin_unlock(&configfs_dirent_lock);207181···237209238210int configfs_make_dirent(struct configfs_dirent * parent_sd,239211 struct dentry * dentry, void * element,240240- umode_t mode, int type)212212+ umode_t mode, int type, struct configfs_fragment *frag)241213{242214 struct configfs_dirent * sd;243215244244- sd = configfs_new_dirent(parent_sd, element, type);216216+ sd = configfs_new_dirent(parent_sd, element, type, frag);245217 if (IS_ERR(sd))246218 return PTR_ERR(sd);247219···288260 * until it is validated by configfs_dir_set_ready()289261 */290262291291-static int configfs_create_dir(struct config_item *item, struct dentry *dentry)263263+static int configfs_create_dir(struct config_item *item, struct dentry *dentry,264264+ struct configfs_fragment *frag)292265{293266 int error;294267 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;···302273 return error;303274304275 error = configfs_make_dirent(p->d_fsdata, dentry, item, mode,305305- CONFIGFS_DIR | CONFIGFS_USET_CREATING);276276+ CONFIGFS_DIR | CONFIGFS_USET_CREATING,277277+ frag);306278 if (unlikely(error))307279 return error;308280···368338{369339 int err = 0;370340 umode_t mode = S_IFLNK | S_IRWXUGO;341341+ struct configfs_dirent *p = parent->d_fsdata;371342372372- err = configfs_make_dirent(parent->d_fsdata, dentry, sl, mode,373373- CONFIGFS_ITEM_LINK);343343+ err = configfs_make_dirent(p, dentry, sl, mode,344344+ CONFIGFS_ITEM_LINK, p->s_frag);374345 if (!err) {375346 err = configfs_create(dentry, mode, init_symlink);376347 if (err) {···630599631600static int configfs_attach_group(struct config_item *parent_item,632601 struct config_item *item,633633- struct dentry *dentry);602602+ struct dentry *dentry,603603+ struct configfs_fragment *frag);634604static void configfs_detach_group(struct config_item *item);635605636606static void detach_groups(struct config_group *group)···679647 * try using vfs_mkdir. Just a thought.680648 */681649static int create_default_group(struct config_group *parent_group,682682- struct config_group *group)650650+ struct config_group *group,651651+ struct configfs_fragment *frag)683652{684653 int ret;685654 struct configfs_dirent *sd;···696663 d_add(child, NULL);697664698665 ret = configfs_attach_group(&parent_group->cg_item,699699- &group->cg_item, child);666666+ &group->cg_item, child, frag);700667 if (!ret) {701668 sd = child->d_fsdata;702669 sd->s_type |= CONFIGFS_USET_DEFAULT;···710677 return ret;711678}712679713713-static int populate_groups(struct config_group *group)680680+static int populate_groups(struct config_group *group,681681+ struct configfs_fragment *frag)714682{715683 struct config_group *new_group;716684 int ret = 0;717685718686 list_for_each_entry(new_group, &group->default_groups, group_entry) {719719- ret = create_default_group(group, new_group);687687+ ret = create_default_group(group, new_group, frag);720688 if (ret) {721689 detach_groups(group);722690 break;···831797 */832798static int configfs_attach_item(struct config_item *parent_item,833799 struct config_item *item,834834- struct dentry *dentry)800800+ struct dentry *dentry,801801+ struct configfs_fragment *frag)835802{836803 int ret;837804838838- ret = configfs_create_dir(item, dentry);805805+ ret = configfs_create_dir(item, dentry, frag);839806 if (!ret) {840807 ret = populate_attrs(item);841808 if (ret) {···866831867832static int configfs_attach_group(struct config_item *parent_item,868833 struct config_item *item,869869- struct dentry *dentry)834834+ struct dentry *dentry,835835+ struct configfs_fragment *frag)870836{871837 int ret;872838 struct configfs_dirent *sd;873839874874- ret = configfs_attach_item(parent_item, item, dentry);840840+ ret = configfs_attach_item(parent_item, item, dentry, frag);875841 if (!ret) {876842 sd = dentry->d_fsdata;877843 sd->s_type |= CONFIGFS_USET_DIR;···888852 */889853 inode_lock_nested(d_inode(dentry), I_MUTEX_CHILD);890854 configfs_adjust_dir_dirent_depth_before_populate(sd);891891- ret = populate_groups(to_config_group(item));855855+ ret = populate_groups(to_config_group(item), frag);892856 if (ret) {893857 configfs_detach_item(item);894858 d_inode(dentry)->i_flags |= S_DEAD;···12831247 struct configfs_dirent *sd;12841248 const struct config_item_type *type;12851249 struct module *subsys_owner = NULL, *new_item_owner = NULL;12501250+ struct configfs_fragment *frag;12861251 char *name;1287125212881253 sd = dentry->d_parent->d_fsdata;···1299126213001263 if (!(sd->s_type & CONFIGFS_USET_DIR)) {13011264 ret = -EPERM;12651265+ goto out;12661266+ }12671267+12681268+ frag = new_fragment();12691269+ if (!frag) {12701270+ ret = -ENOMEM;13021271 goto out;13031272 }13041273···14101367 spin_unlock(&configfs_dirent_lock);1411136814121369 if (group)14131413- ret = configfs_attach_group(parent_item, item, dentry);13701370+ ret = configfs_attach_group(parent_item, item, dentry, frag);14141371 else14151415- ret = configfs_attach_item(parent_item, item, dentry);13721372+ ret = configfs_attach_item(parent_item, item, dentry, frag);1416137314171374 spin_lock(&configfs_dirent_lock);14181375 sd->s_type &= ~CONFIGFS_USET_IN_MKDIR;···14491406 * reference.14501407 */14511408 config_item_put(parent_item);14091409+ put_fragment(frag);1452141014531411out:14541412 return ret;···14611417 struct config_item *item;14621418 struct configfs_subsystem *subsys;14631419 struct configfs_dirent *sd;14201420+ struct configfs_fragment *frag;14641421 struct module *subsys_owner = NULL, *dead_item_owner = NULL;14651422 int ret;14661423···15181473 dput(wait);15191474 }15201475 } while (ret == -EAGAIN);14761476+14771477+ frag = sd->s_frag;14781478+ if (down_write_killable(&frag->frag_sem)) {14791479+ spin_lock(&configfs_dirent_lock);14801480+ configfs_detach_rollback(dentry);14811481+ spin_unlock(&configfs_dirent_lock);14821482+ return -EINTR;14831483+ }14841484+ frag->frag_dead = true;14851485+ up_write(&frag->frag_sem);1521148615221487 /* Get a working ref for the duration of this function */15231488 item = configfs_get_config_item(dentry);···16291574 */16301575 err = -ENOENT;16311576 if (configfs_dirent_is_ready(parent_sd)) {16321632- file->private_data = configfs_new_dirent(parent_sd, NULL, 0);15771577+ file->private_data = configfs_new_dirent(parent_sd, NULL, 0, NULL);16331578 if (IS_ERR(file->private_data))16341579 err = PTR_ERR(file->private_data);16351580 else···17871732{17881733 struct configfs_subsystem *subsys = parent_group->cg_subsys;17891734 struct dentry *parent;17351735+ struct configfs_fragment *frag;17901736 int ret;17371737+17381738+ frag = new_fragment();17391739+ if (!frag)17401740+ return -ENOMEM;1791174117921742 mutex_lock(&subsys->su_mutex);17931743 link_group(parent_group, group);···18011741 parent = parent_group->cg_item.ci_dentry;1802174218031743 inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);18041804- ret = create_default_group(parent_group, group);17441744+ ret = create_default_group(parent_group, group, frag);18051745 if (ret)18061746 goto err_out;18071747···18091749 configfs_dir_set_ready(group->cg_item.ci_dentry->d_fsdata);18101750 spin_unlock(&configfs_dirent_lock);18111751 inode_unlock(d_inode(parent));17521752+ put_fragment(frag);18121753 return 0;18131754err_out:18141755 inode_unlock(d_inode(parent));18151756 mutex_lock(&subsys->su_mutex);18161757 unlink_group(group);18171758 mutex_unlock(&subsys->su_mutex);17591759+ put_fragment(frag);18181760 return ret;18191761}18201762EXPORT_SYMBOL(configfs_register_group);···18321770 struct configfs_subsystem *subsys = group->cg_subsys;18331771 struct dentry *dentry = group->cg_item.ci_dentry;18341772 struct dentry *parent = group->cg_item.ci_parent->ci_dentry;17731773+ struct configfs_dirent *sd = dentry->d_fsdata;17741774+ struct configfs_fragment *frag = sd->s_frag;1835177518361836- mutex_lock(&subsys->su_mutex);18371837- if (!group->cg_item.ci_parent->ci_group) {18381838- /*18391839- * The parent has already been unlinked and detached18401840- * due to a rmdir.18411841- */18421842- goto unlink_group;18431843- }18441844- mutex_unlock(&subsys->su_mutex);17761776+ down_write(&frag->frag_sem);17771777+ frag->frag_dead = true;17781778+ up_write(&frag->frag_sem);1845177918461780 inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);18471781 spin_lock(&configfs_dirent_lock);···18541796 dput(dentry);1855179718561798 mutex_lock(&subsys->su_mutex);18571857-unlink_group:18581799 unlink_group(group);18591800 mutex_unlock(&subsys->su_mutex);18601801}···19101853 struct dentry *dentry;19111854 struct dentry *root;19121855 struct configfs_dirent *sd;18561856+ struct configfs_fragment *frag;18571857+18581858+ frag = new_fragment();18591859+ if (!frag)18601860+ return -ENOMEM;1913186119141862 root = configfs_pin_fs();19151915- if (IS_ERR(root))18631863+ if (IS_ERR(root)) {18641864+ put_fragment(frag);19161865 return PTR_ERR(root);18661866+ }1917186719181868 if (!group->cg_item.ci_name)19191869 group->cg_item.ci_name = group->cg_item.ci_namebuf;···19361872 d_add(dentry, NULL);1937187319381874 err = configfs_attach_group(sd->s_element, &group->cg_item,19391939- dentry);18751875+ dentry, frag);19401876 if (err) {19411877 BUG_ON(d_inode(dentry));19421878 d_drop(dentry);···19541890 unlink_group(group);19551891 configfs_release_fs();19561892 }18931893+ put_fragment(frag);1957189419581895 return err;19591896}···19641899 struct config_group *group = &subsys->su_group;19651900 struct dentry *dentry = group->cg_item.ci_dentry;19661901 struct dentry *root = dentry->d_sb->s_root;19021902+ struct configfs_dirent *sd = dentry->d_fsdata;19031903+ struct configfs_fragment *frag = sd->s_frag;1967190419681905 if (dentry->d_parent != root) {19691906 pr_err("Tried to unregister non-subsystem!\n");19701907 return;19711908 }19091909+19101910+ down_write(&frag->frag_sem);19111911+ frag->frag_dead = true;19121912+ up_write(&frag->frag_sem);1972191319731914 inode_lock_nested(d_inode(root),19741915 I_MUTEX_PARENT);
+138-138
fs/configfs/file.c
···3939 bool write_in_progress;4040 char *bin_buffer;4141 int bin_buffer_size;4242+ int cb_max_size;4343+ struct config_item *item;4444+ struct module *owner;4545+ union {4646+ struct configfs_attribute *attr;4747+ struct configfs_bin_attribute *bin_attr;4848+ };4249};43504444-4545-/**4646- * fill_read_buffer - allocate and fill buffer from item.4747- * @dentry: dentry pointer.4848- * @buffer: data buffer for file.4949- *5050- * Allocate @buffer->page, if it hasn't been already, then call the5151- * config_item's show() method to fill the buffer with this attribute's5252- * data.5353- * This is called only once, on the file's first read.5454- */5555-static int fill_read_buffer(struct dentry * dentry, struct configfs_buffer * buffer)5151+static inline struct configfs_fragment *to_frag(struct file *file)5652{5757- struct configfs_attribute * attr = to_attr(dentry);5858- struct config_item * item = to_item(dentry->d_parent);5959- int ret = 0;6060- ssize_t count;5353+ struct configfs_dirent *sd = file->f_path.dentry->d_fsdata;5454+5555+ return sd->s_frag;5656+}5757+5858+static int fill_read_buffer(struct file *file, struct configfs_buffer *buffer)5959+{6060+ struct configfs_fragment *frag = to_frag(file);6161+ ssize_t count = -ENOENT;61626263 if (!buffer->page)6364 buffer->page = (char *) get_zeroed_page(GFP_KERNEL);6465 if (!buffer->page)6566 return -ENOMEM;66676767- count = attr->show(item, buffer->page);6868+ down_read(&frag->frag_sem);6969+ if (!frag->frag_dead)7070+ count = buffer->attr->show(buffer->item, buffer->page);7171+ up_read(&frag->frag_sem);68726969- BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE);7070- if (count >= 0) {7171- buffer->needs_read_fill = 0;7272- buffer->count = count;7373- } else7474- ret = count;7575- return ret;7373+ if (count < 0)7474+ return count;7575+ if (WARN_ON_ONCE(count > (ssize_t)SIMPLE_ATTR_SIZE))7676+ return -EIO;7777+ buffer->needs_read_fill = 0;7878+ buffer->count = count;7979+ return 0;7680}77817882/**···10197static ssize_t10298configfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos)10399{104104- struct configfs_buffer * buffer = file->private_data;100100+ struct configfs_buffer *buffer = file->private_data;105101 ssize_t retval = 0;106102107103 mutex_lock(&buffer->mutex);108104 if (buffer->needs_read_fill) {109109- if ((retval = fill_read_buffer(file->f_path.dentry,buffer)))105105+ retval = fill_read_buffer(file, buffer);106106+ if (retval)110107 goto out;111108 }112109 pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n",···143138configfs_read_bin_file(struct file *file, char __user *buf,144139 size_t count, loff_t *ppos)145140{141141+ struct configfs_fragment *frag = to_frag(file);146142 struct configfs_buffer *buffer = file->private_data;147147- struct dentry *dentry = file->f_path.dentry;148148- struct config_item *item = to_item(dentry->d_parent);149149- struct configfs_bin_attribute *bin_attr = to_bin_attr(dentry);150143 ssize_t retval = 0;151144 ssize_t len = min_t(size_t, count, PAGE_SIZE);152145···159156160157 if (buffer->needs_read_fill) {161158 /* perform first read with buf == NULL to get extent */162162- len = bin_attr->read(item, NULL, 0);159159+ down_read(&frag->frag_sem);160160+ if (!frag->frag_dead)161161+ len = buffer->bin_attr->read(buffer->item, NULL, 0);162162+ else163163+ len = -ENOENT;164164+ up_read(&frag->frag_sem);163165 if (len <= 0) {164166 retval = len;165167 goto out;166168 }167169168170 /* do not exceed the maximum value */169169- if (bin_attr->cb_max_size && len > bin_attr->cb_max_size) {171171+ if (buffer->cb_max_size && len > buffer->cb_max_size) {170172 retval = -EFBIG;171173 goto out;172174 }···184176 buffer->bin_buffer_size = len;185177186178 /* perform second read to fill buffer */187187- len = bin_attr->read(item, buffer->bin_buffer, len);179179+ down_read(&frag->frag_sem);180180+ if (!frag->frag_dead)181181+ len = buffer->bin_attr->read(buffer->item,182182+ buffer->bin_buffer, len);183183+ else184184+ len = -ENOENT;185185+ up_read(&frag->frag_sem);188186 if (len < 0) {189187 retval = len;190188 vfree(buffer->bin_buffer);···240226 return error ? -EFAULT : count;241227}242228243243-244244-/**245245- * flush_write_buffer - push buffer to config_item.246246- * @dentry: dentry to the attribute247247- * @buffer: data buffer for file.248248- * @count: number of bytes249249- *250250- * Get the correct pointers for the config_item and the attribute we're251251- * dealing with, then call the store() method for the attribute,252252- * passing the buffer that we acquired in fill_write_buffer().253253- */254254-255229static int256256-flush_write_buffer(struct dentry * dentry, struct configfs_buffer * buffer, size_t count)230230+flush_write_buffer(struct file *file, struct configfs_buffer *buffer, size_t count)257231{258258- struct configfs_attribute * attr = to_attr(dentry);259259- struct config_item * item = to_item(dentry->d_parent);232232+ struct configfs_fragment *frag = to_frag(file);233233+ int res = -ENOENT;260234261261- return attr->store(item, buffer->page, count);235235+ down_read(&frag->frag_sem);236236+ if (!frag->frag_dead)237237+ res = buffer->attr->store(buffer->item, buffer->page, count);238238+ up_read(&frag->frag_sem);239239+ return res;262240}263241264242···274268static ssize_t275269configfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t *ppos)276270{277277- struct configfs_buffer * buffer = file->private_data;271271+ struct configfs_buffer *buffer = file->private_data;278272 ssize_t len;279273280274 mutex_lock(&buffer->mutex);281275 len = fill_write_buffer(buffer, buf, count);282276 if (len > 0)283283- len = flush_write_buffer(file->f_path.dentry, buffer, len);277277+ len = flush_write_buffer(file, buffer, len);284278 if (len > 0)285279 *ppos += len;286280 mutex_unlock(&buffer->mutex);···305299 size_t count, loff_t *ppos)306300{307301 struct configfs_buffer *buffer = file->private_data;308308- struct dentry *dentry = file->f_path.dentry;309309- struct configfs_bin_attribute *bin_attr = to_bin_attr(dentry);310302 void *tbuf = NULL;311303 ssize_t len;312304···320316 /* buffer grows? */321317 if (*ppos + count > buffer->bin_buffer_size) {322318323323- if (bin_attr->cb_max_size &&324324- *ppos + count > bin_attr->cb_max_size) {319319+ if (buffer->cb_max_size &&320320+ *ppos + count > buffer->cb_max_size) {325321 len = -EFBIG;326322 goto out;327323 }···353349 return len;354350}355351356356-static int check_perm(struct inode * inode, struct file * file, int type)352352+static int __configfs_open_file(struct inode *inode, struct file *file, int type)357353{358358- struct config_item *item = configfs_get_config_item(file->f_path.dentry->d_parent);359359- struct configfs_attribute * attr = to_attr(file->f_path.dentry);360360- struct configfs_bin_attribute *bin_attr = NULL;361361- struct configfs_buffer * buffer;362362- struct configfs_item_operations * ops = NULL;363363- int error = 0;354354+ struct dentry *dentry = file->f_path.dentry;355355+ struct configfs_fragment *frag = to_frag(file);356356+ struct configfs_attribute *attr;357357+ struct configfs_buffer *buffer;358358+ int error;364359365365- if (!item || !attr)366366- goto Einval;360360+ error = -ENOMEM;361361+ buffer = kzalloc(sizeof(struct configfs_buffer), GFP_KERNEL);362362+ if (!buffer)363363+ goto out;367364368368- if (type & CONFIGFS_ITEM_BIN_ATTR)369369- bin_attr = to_bin_attr(file->f_path.dentry);365365+ error = -ENOENT;366366+ down_read(&frag->frag_sem);367367+ if (unlikely(frag->frag_dead))368368+ goto out_free_buffer;370369371371- /* Grab the module reference for this attribute if we have one */372372- if (!try_module_get(attr->ca_owner)) {373373- error = -ENODEV;374374- goto Done;370370+ error = -EINVAL;371371+ buffer->item = to_item(dentry->d_parent);372372+ if (!buffer->item)373373+ goto out_free_buffer;374374+375375+ attr = to_attr(dentry);376376+ if (!attr)377377+ goto out_put_item;378378+379379+ if (type & CONFIGFS_ITEM_BIN_ATTR) {380380+ buffer->bin_attr = to_bin_attr(dentry);381381+ buffer->cb_max_size = buffer->bin_attr->cb_max_size;382382+ } else {383383+ buffer->attr = attr;375384 }376385377377- if (item->ci_type)378378- ops = item->ci_type->ct_item_ops;379379- else380380- goto Eaccess;386386+ buffer->owner = attr->ca_owner;387387+ /* Grab the module reference for this attribute if we have one */388388+ error = -ENODEV;389389+ if (!try_module_get(buffer->owner))390390+ goto out_put_item;391391+392392+ error = -EACCES;393393+ if (!buffer->item->ci_type)394394+ goto out_put_module;395395+396396+ buffer->ops = buffer->item->ci_type->ct_item_ops;381397382398 /* File needs write support.383399 * The inode's perms must say it's ok,···405381 */406382 if (file->f_mode & FMODE_WRITE) {407383 if (!(inode->i_mode & S_IWUGO))408408- goto Eaccess;409409-384384+ goto out_put_module;410385 if ((type & CONFIGFS_ITEM_ATTR) && !attr->store)411411- goto Eaccess;412412-413413- if ((type & CONFIGFS_ITEM_BIN_ATTR) && !bin_attr->write)414414- goto Eaccess;386386+ goto out_put_module;387387+ if ((type & CONFIGFS_ITEM_BIN_ATTR) && !buffer->bin_attr->write)388388+ goto out_put_module;415389 }416390417391 /* File needs read support.···418396 */419397 if (file->f_mode & FMODE_READ) {420398 if (!(inode->i_mode & S_IRUGO))421421- goto Eaccess;422422-399399+ goto out_put_module;423400 if ((type & CONFIGFS_ITEM_ATTR) && !attr->show)424424- goto Eaccess;425425-426426- if ((type & CONFIGFS_ITEM_BIN_ATTR) && !bin_attr->read)427427- goto Eaccess;401401+ goto out_put_module;402402+ if ((type & CONFIGFS_ITEM_BIN_ATTR) && !buffer->bin_attr->read)403403+ goto out_put_module;428404 }429405430430- /* No error? Great, allocate a buffer for the file, and store it431431- * it in file->private_data for easy access.432432- */433433- buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL);434434- if (!buffer) {435435- error = -ENOMEM;436436- goto Enomem;437437- }438406 mutex_init(&buffer->mutex);439407 buffer->needs_read_fill = 1;440408 buffer->read_in_progress = false;441409 buffer->write_in_progress = false;442442- buffer->ops = ops;443410 file->private_data = buffer;444444- goto Done;411411+ up_read(&frag->frag_sem);412412+ return 0;445413446446- Einval:447447- error = -EINVAL;448448- goto Done;449449- Eaccess:450450- error = -EACCES;451451- Enomem:452452- module_put(attr->ca_owner);453453- Done:454454- if (error && item)455455- config_item_put(item);414414+out_put_module:415415+ module_put(buffer->owner);416416+out_put_item:417417+ config_item_put(buffer->item);418418+out_free_buffer:419419+ up_read(&frag->frag_sem);420420+ kfree(buffer);421421+out:456422 return error;457423}458424459425static int configfs_release(struct inode *inode, struct file *filp)460426{461461- struct config_item * item = to_item(filp->f_path.dentry->d_parent);462462- struct configfs_attribute * attr = to_attr(filp->f_path.dentry);463463- struct module * owner = attr->ca_owner;464464- struct configfs_buffer * buffer = filp->private_data;427427+ struct configfs_buffer *buffer = filp->private_data;465428466466- if (item)467467- config_item_put(item);468468- /* After this point, attr should not be accessed. */469469- module_put(owner);470470-471471- if (buffer) {472472- if (buffer->page)473473- free_page((unsigned long)buffer->page);474474- mutex_destroy(&buffer->mutex);475475- kfree(buffer);476476- }429429+ module_put(buffer->owner);430430+ if (buffer->page)431431+ free_page((unsigned long)buffer->page);432432+ mutex_destroy(&buffer->mutex);433433+ kfree(buffer);477434 return 0;478435}479436480437static int configfs_open_file(struct inode *inode, struct file *filp)481438{482482- return check_perm(inode, filp, CONFIGFS_ITEM_ATTR);439439+ return __configfs_open_file(inode, filp, CONFIGFS_ITEM_ATTR);483440}484441485442static int configfs_open_bin_file(struct inode *inode, struct file *filp)486443{487487- return check_perm(inode, filp, CONFIGFS_ITEM_BIN_ATTR);444444+ return __configfs_open_file(inode, filp, CONFIGFS_ITEM_BIN_ATTR);488445}489446490490-static int configfs_release_bin_file(struct inode *inode, struct file *filp)447447+static int configfs_release_bin_file(struct inode *inode, struct file *file)491448{492492- struct configfs_buffer *buffer = filp->private_data;493493- struct dentry *dentry = filp->f_path.dentry;494494- struct config_item *item = to_item(dentry->d_parent);495495- struct configfs_bin_attribute *bin_attr = to_bin_attr(dentry);496496- ssize_t len = 0;497497- int ret;449449+ struct configfs_buffer *buffer = file->private_data;498450499451 buffer->read_in_progress = false;500452501453 if (buffer->write_in_progress) {454454+ struct configfs_fragment *frag = to_frag(file);502455 buffer->write_in_progress = false;503456504504- len = bin_attr->write(item, buffer->bin_buffer,505505- buffer->bin_buffer_size);506506-457457+ down_read(&frag->frag_sem);458458+ if (!frag->frag_dead) {459459+ /* result of ->release() is ignored */460460+ buffer->bin_attr->write(buffer->item,461461+ buffer->bin_buffer,462462+ buffer->bin_buffer_size);463463+ }464464+ up_read(&frag->frag_sem);507465 /* vfree on NULL is safe */508466 vfree(buffer->bin_buffer);509467 buffer->bin_buffer = NULL;···491489 buffer->needs_read_fill = 1;492490 }493491494494- ret = configfs_release(inode, filp);495495- if (len < 0)496496- return len;497497- return ret;492492+ configfs_release(inode, file);493493+ return 0;498494}499495500496···527527528528 inode_lock_nested(d_inode(dir), I_MUTEX_NORMAL);529529 error = configfs_make_dirent(parent_sd, NULL, (void *) attr, mode,530530- CONFIGFS_ITEM_ATTR);530530+ CONFIGFS_ITEM_ATTR, parent_sd->s_frag);531531 inode_unlock(d_inode(dir));532532533533 return error;···549549550550 inode_lock_nested(dir->d_inode, I_MUTEX_NORMAL);551551 error = configfs_make_dirent(parent_sd, NULL, (void *) bin_attr, mode,552552- CONFIGFS_ITEM_BIN_ATTR);552552+ CONFIGFS_ITEM_BIN_ATTR, parent_sd->s_frag);553553 inode_unlock(dir->d_inode);554554555555 return error;
+10-8
fs/nfs/inode.c
···14031403 if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))14041404 return 0;1405140514061406- /* No fileid? Just exit */14071407- if (!(fattr->valid & NFS_ATTR_FATTR_FILEID))14081408- return 0;14061406+ if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) {14071407+ /* Only a mounted-on-fileid? Just exit */14081408+ if (fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)14091409+ return 0;14091410 /* Has the inode gone and changed behind our back? */14101410- if (nfsi->fileid != fattr->fileid) {14111411+ } else if (nfsi->fileid != fattr->fileid) {14111412 /* Is this perhaps the mounted-on fileid? */14121413 if ((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) &&14131414 nfsi->fileid == fattr->mounted_on_fileid)···18081807 nfs_display_fhandle_hash(NFS_FH(inode)),18091808 atomic_read(&inode->i_count), fattr->valid);1810180918111811- /* No fileid? Just exit */18121812- if (!(fattr->valid & NFS_ATTR_FATTR_FILEID))18131813- return 0;18101810+ if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) {18111811+ /* Only a mounted-on-fileid? Just exit */18121812+ if (fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)18131813+ return 0;18141814 /* Has the inode gone and changed behind our back? */18151815- if (nfsi->fileid != fattr->fileid) {18151815+ } else if (nfsi->fileid != fattr->fileid) {18161816 /* Is this perhaps the mounted-on fileid? */18171817 if ((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) &&18181818 nfsi->fileid == fattr->mounted_on_fileid)
···276276 *cmd &= ~IPC_64;277277 return version;278278}279279-#endif280279281281-/* for __ARCH_WANT_SYS_IPC */282282-long ksys_semtimedop(int semid, struct sembuf __user *tsops,283283- unsigned int nsops,284284- const struct __kernel_timespec __user *timeout);285285-long ksys_semget(key_t key, int nsems, int semflg);286286-long ksys_old_semctl(int semid, int semnum, int cmd, unsigned long arg);287287-long ksys_msgget(key_t key, int msgflg);288288-long ksys_old_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);289289-long ksys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz,290290- long msgtyp, int msgflg);291291-long ksys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz,292292- int msgflg);293293-long ksys_shmget(key_t key, size_t size, int shmflg);294294-long ksys_shmdt(char __user *shmaddr);295295-long ksys_old_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);296296-297297-/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */298298-long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,299299- unsigned int nsops,300300- const struct old_timespec32 __user *timeout);301301-#ifdef CONFIG_COMPAT302280long compat_ksys_old_semctl(int semid, int semnum, int cmd, int arg);303281long compat_ksys_old_msgctl(int msqid, int cmd, void __user *uptr);304282long compat_ksys_msgrcv(int msqid, compat_uptr_t msgp, compat_ssize_t msgsz,···284306long compat_ksys_msgsnd(int msqid, compat_uptr_t msgp,285307 compat_ssize_t msgsz, int msgflg);286308long compat_ksys_old_shmctl(int shmid, int cmd, void __user *uptr);287287-#endif /* CONFIG_COMPAT */309309+310310+#endif288311289312#endif
+14-9
kernel/bpf/verifier.c
···17721772 bitmap_from_u64(mask, stack_mask);17731773 for_each_set_bit(i, mask, 64) {17741774 if (i >= func->allocated_stack / BPF_REG_SIZE) {17751775- /* This can happen if backtracking17761776- * is propagating stack precision where17771777- * caller has larger stack frame17781778- * than callee, but backtrack_insn() should17791779- * have returned -ENOTSUPP.17751775+ /* the sequence of instructions:17761776+ * 2: (bf) r3 = r1017771777+ * 3: (7b) *(u64 *)(r3 -8) = r017781778+ * 4: (79) r4 = *(u64 *)(r10 -8)17791779+ * doesn't contain jmps. It's backtracked17801780+ * as a single block.17811781+ * During backtracking insn 3 is not recognized as17821782+ * stack access, so at the end of backtracking17831783+ * stack slot fp-8 is still marked in stack_mask.17841784+ * However the parent state may not have accessed17851785+ * fp-8 and it's "unallocated" stack space.17861786+ * In such case fallback to conservative.17801787 */17811781- verbose(env, "BUG spi %d stack_size %d\n",17821782- i, func->allocated_stack);17831783- WARN_ONCE(1, "verifier backtracking bug");17841784- return -EFAULT;17881788+ mark_all_scalars_precise(env, st);17891789+ return 0;17851790 }1786179117871792 if (func->stack[i].slot_type[0] != STACK_SPILL) {
+9-1
kernel/cgroup/cgroup.c
···52555255 * if the parent has to be frozen, the child has too.52565256 */52575257 cgrp->freezer.e_freeze = parent->freezer.e_freeze;52585258- if (cgrp->freezer.e_freeze)52585258+ if (cgrp->freezer.e_freeze) {52595259+ /*52605260+ * Set the CGRP_FREEZE flag, so when a process will be52615261+ * attached to the child cgroup, it will become frozen.52625262+ * At this point the new cgroup is unpopulated, so we can52635263+ * consider it frozen immediately.52645264+ */52655265+ set_bit(CGRP_FREEZE, &cgrp->flags);52595266 set_bit(CGRP_FROZEN, &cgrp->flags);52675267+ }5260526852615269 spin_lock_irq(&css_set_lock);52625270 for (tcgrp = cgrp; tcgrp; tcgrp = cgroup_parent(tcgrp)) {
···23382338 *23392339 * It copies the process, and if successful kick-starts23402340 * it and waits for it to finish using the VM if required.23412341+ *23422342+ * args->exit_signal is expected to be checked for sanity by the caller.23412343 */23422344long _do_fork(struct kernel_clone_args *args)23432345{···2563256125642562 if (copy_from_user(&args, uargs, size))25652563 return -EFAULT;25642564+25652565+ /*25662566+ * Verify that higher 32bits of exit_signal are unset and that25672567+ * it is a valid signal25682568+ */25692569+ if (unlikely((args.exit_signal & ~((u64)CSIGNAL)) ||25702570+ !valid_signal(args.exit_signal)))25712571+ return -EINVAL;2566257225672573 *kargs = (struct kernel_clone_args){25682574 .flags = args.flags,
···51055105 return retval;51065106}5107510751085108-static int sched_read_attr(struct sched_attr __user *uattr,51095109- struct sched_attr *attr,51105110- unsigned int usize)51085108+/*51095109+ * Copy the kernel size attribute structure (which might be larger51105110+ * than what user-space knows about) to user-space.51115111+ *51125112+ * Note that all cases are valid: user-space buffer can be larger or51135113+ * smaller than the kernel-space buffer. The usual case is that both51145114+ * have the same size.51155115+ */51165116+static int51175117+sched_attr_copy_to_user(struct sched_attr __user *uattr,51185118+ struct sched_attr *kattr,51195119+ unsigned int usize)51115120{51125112- int ret;51215121+ unsigned int ksize = sizeof(*kattr);5113512251145123 if (!access_ok(uattr, usize))51155124 return -EFAULT;5116512551175126 /*51185118- * If we're handed a smaller struct than we know of,51195119- * ensure all the unknown bits are 0 - i.e. old51205120- * user-space does not get uncomplete information.51275127+ * sched_getattr() ABI forwards and backwards compatibility:51285128+ *51295129+ * If usize == ksize then we just copy everything to user-space and all is good.51305130+ *51315131+ * If usize < ksize then we only copy as much as user-space has space for,51325132+ * this keeps ABI compatibility as well. We skip the rest.51335133+ *51345134+ * If usize > ksize then user-space is using a newer version of the ABI,51355135+ * which part the kernel doesn't know about. Just ignore it - tooling can51365136+ * detect the kernel's knowledge of attributes from the attr->size value51375137+ * which is set to ksize in this case.51215138 */51225122- if (usize < sizeof(*attr)) {51235123- unsigned char *addr;51245124- unsigned char *end;51395139+ kattr->size = min(usize, ksize);5125514051265126- addr = (void *)attr + usize;51275127- end = (void *)attr + sizeof(*attr);51285128-51295129- for (; addr < end; addr++) {51305130- if (*addr)51315131- return -EFBIG;51325132- }51335133-51345134- attr->size = usize;51355135- }51365136-51375137- ret = copy_to_user(uattr, attr, attr->size);51385138- if (ret)51415141+ if (copy_to_user(uattr, kattr, kattr->size))51395142 return -EFAULT;5140514351415144 return 0;···51485145 * sys_sched_getattr - similar to sched_getparam, but with sched_attr51495146 * @pid: the pid in question.51505147 * @uattr: structure containing the extended parameters.51515151- * @size: sizeof(attr) for fwd/bwd comp.51485148+ * @usize: sizeof(attr) that user-space knows about, for forwards and backwards compatibility.51525149 * @flags: for future extension.51535150 */51545151SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr,51555155- unsigned int, size, unsigned int, flags)51525152+ unsigned int, usize, unsigned int, flags)51565153{51575157- struct sched_attr attr = {51585158- .size = sizeof(struct sched_attr),51595159- };51545154+ struct sched_attr kattr = { };51605155 struct task_struct *p;51615156 int retval;5162515751635163- if (!uattr || pid < 0 || size > PAGE_SIZE ||51645164- size < SCHED_ATTR_SIZE_VER0 || flags)51585158+ if (!uattr || pid < 0 || usize > PAGE_SIZE ||51595159+ usize < SCHED_ATTR_SIZE_VER0 || flags)51655160 return -EINVAL;5166516151675162 rcu_read_lock();···51725171 if (retval)51735172 goto out_unlock;5174517351755175- attr.sched_policy = p->policy;51745174+ kattr.sched_policy = p->policy;51765175 if (p->sched_reset_on_fork)51775177- attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;51765176+ kattr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;51785177 if (task_has_dl_policy(p))51795179- __getparam_dl(p, &attr);51785178+ __getparam_dl(p, &kattr);51805179 else if (task_has_rt_policy(p))51815181- attr.sched_priority = p->rt_priority;51805180+ kattr.sched_priority = p->rt_priority;51825181 else51835183- attr.sched_nice = task_nice(p);51825182+ kattr.sched_nice = task_nice(p);5184518351855184#ifdef CONFIG_UCLAMP_TASK51865186- attr.sched_util_min = p->uclamp_req[UCLAMP_MIN].value;51875187- attr.sched_util_max = p->uclamp_req[UCLAMP_MAX].value;51855185+ kattr.sched_util_min = p->uclamp_req[UCLAMP_MIN].value;51865186+ kattr.sched_util_max = p->uclamp_req[UCLAMP_MAX].value;51885187#endif5189518851905189 rcu_read_unlock();5191519051925192- retval = sched_read_attr(uattr, &attr, size);51935193- return retval;51915191+ return sched_attr_copy_to_user(uattr, &kattr, usize);5194519251955193out_unlock:51965194 rcu_read_unlock();
+5
kernel/sched/fair.c
···44704470 if (likely(cfs_rq->runtime_remaining > 0))44714471 return;4472447244734473+ if (cfs_rq->throttled)44744474+ return;44734475 /*44744476 * if we're unable to extend our runtime we resched so that the active44754477 * hierarchy can be throttled···46744672 rq_lock_irqsave(rq, &rf);46754673 if (!cfs_rq_throttled(cfs_rq))46764674 goto next;46754675+46764676+ /* By the above check, this should never be true */46774677+ SCHED_WARN_ON(cfs_rq->runtime_remaining > 0);4677467846784679 runtime = -cfs_rq->runtime_remaining + 1;46794680 if (runtime > remaining)
+3-3
lib/Kconfig
···631631config PARMAN632632 tristate "parman" if COMPILE_TEST633633634634+config OBJAGG635635+ tristate "objagg" if COMPILE_TEST636636+634637config STRING_SELFTEST635638 tristate "Test string functions"636639···656653657654config GENERIC_LIB_UCMPDI2658655 bool659659-660660-config OBJAGG661661- tristate "objagg" if COMPILE_TEST
···496496 if (!brnet->call_ip6tables &&497497 !br_opt_get(br, BROPT_NF_CALL_IP6TABLES))498498 return NF_ACCEPT;499499+ if (!ipv6_mod_enabled()) {500500+ pr_warn_once("Module ipv6 is disabled, so call_ip6tables is not supported.");501501+ return NF_DROP;502502+ }499503500504 nf_bridge_pull_encap_header_rcsum(skb);501505 return br_nf_pre_routing_ipv6(priv, skb, state);
···36703670 int pos;36713671 int dummy;3672367236733673+ if (list_skb && !list_skb->head_frag && skb_headlen(list_skb) &&36743674+ (skb_shinfo(head_skb)->gso_type & SKB_GSO_DODGY)) {36753675+ /* gso_size is untrusted, and we have a frag_list with a linear36763676+ * non head_frag head.36773677+ *36783678+ * (we assume checking the first list_skb member suffices;36793679+ * i.e if either of the list_skb members have non head_frag36803680+ * head, then the first one has too).36813681+ *36823682+ * If head_skb's headlen does not fit requested gso_size, it36833683+ * means that the frag_list members do NOT terminate on exact36843684+ * gso_size boundaries. Hence we cannot perform skb_frag_t page36853685+ * sharing. Therefore we must fallback to copying the frag_list36863686+ * skbs; we do so by disabling SG.36873687+ */36883688+ if (mss != GSO_BY_FRAGS && mss != skb_headlen(head_skb))36893689+ features &= ~NETIF_F_SG;36903690+ }36913691+36733692 __skb_push(head_skb, doffset);36743693 proto = skb_network_protocol(head_skb, &dummy);36753694 if (unlikely(!proto))
···1414#include <linux/netfilter/nf_tables.h>1515#include <net/netfilter/nf_tables_core.h>1616#include <net/netfilter/nf_tables.h>1717+#include <net/ipv6.h>17181819#include <net/netfilter/nft_fib.h>1920···3534 }3635 break;3736 case ETH_P_IPV6:3737+ if (!ipv6_mod_enabled())3838+ break;3839 switch (priv->result) {3940 case NFT_FIB_RESULT_OIF:4041 case NFT_FIB_RESULT_OIFNAME:
+3-3
net/netfilter/nft_socket.c
···4747 return;4848 }49495050- /* So that subsequent socket matching not to require other lookups. */5151- skb->sk = sk;5252-5350 switch(priv->key) {5451 case NFT_SOCKET_TRANSPARENT:5552 nft_reg_store8(dest, inet_sk_transparent(sk));···6366 WARN_ON(1);6467 regs->verdict.code = NFT_BREAK;6568 }6969+7070+ if (sk != skb->sk)7171+ sock_gen_put(sk);6672}67736874static const struct nla_policy nft_socket_policy[NFTA_SOCKET_MAX + 1] = {
+4-1
net/qrtr/tun.c
···8484 if (!kbuf)8585 return -ENOMEM;86868787- if (!copy_from_iter_full(kbuf, len, from))8787+ if (!copy_from_iter_full(kbuf, len, from)) {8888+ kfree(kbuf);8889 return -EFAULT;9090+ }89919092 ret = qrtr_endpoint_post(&tun->ep, kbuf, len);91939494+ kfree(kbuf);9295 return ret < 0 ? ret : len;9396}9497
+18-22
net/rds/bind.c
···11/*22- * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.22+ * Copyright (c) 2006, 2019 Oracle and/or its affiliates. All rights reserved.33 *44 * This software is available to you under a choice of one of two55 * licenses. You may choose to be licensed under the terms of the GNU···239239 goto out;240240 }241241242242- sock_set_flag(sk, SOCK_RCU_FREE);243243- ret = rds_add_bound(rs, binding_addr, &port, scope_id);244244- if (ret)245245- goto out;246246-247247- if (rs->rs_transport) { /* previously bound */242242+ /* The transport can be set using SO_RDS_TRANSPORT option before the243243+ * socket is bound.244244+ */245245+ if (rs->rs_transport) {248246 trans = rs->rs_transport;249247 if (trans->laddr_check(sock_net(sock->sk),250248 binding_addr, scope_id) != 0) {251249 ret = -ENOPROTOOPT;252252- rds_remove_bound(rs);253253- } else {254254- ret = 0;250250+ goto out;255251 }256256- goto out;257257- }258258- trans = rds_trans_get_preferred(sock_net(sock->sk), binding_addr,259259- scope_id);260260- if (!trans) {261261- ret = -EADDRNOTAVAIL;262262- rds_remove_bound(rs);263263- pr_info_ratelimited("RDS: %s could not find a transport for %pI6c, load rds_tcp or rds_rdma?\n",264264- __func__, binding_addr);265265- goto out;252252+ } else {253253+ trans = rds_trans_get_preferred(sock_net(sock->sk),254254+ binding_addr, scope_id);255255+ if (!trans) {256256+ ret = -EADDRNOTAVAIL;257257+ pr_info_ratelimited("RDS: %s could not find a transport for %pI6c, load rds_tcp or rds_rdma?\n",258258+ __func__, binding_addr);259259+ goto out;260260+ }261261+ rs->rs_transport = trans;266262 }267263268268- rs->rs_transport = trans;269269- ret = 0;264264+ sock_set_flag(sk, SOCK_RCU_FREE);265265+ ret = rds_add_bound(rs, binding_addr, &port, scope_id);270266271267out:272268 release_sock(sk);
···13391339 return status;13401340}1341134113421342-static void __net_init sctp_ctrlsock_exit(struct net *net)13421342+static void __net_exit sctp_ctrlsock_exit(struct net *net)13431343{13441344 /* Free the control endpoint. */13451345 inet_ctl_sock_destroy(net->sctp.ctl_sock);
···6666{6767 struct request_key_auth *rka = dereference_key_rcu(key);68686969+ if (!rka)7070+ return;7171+6972 seq_puts(m, "key:");7073 seq_puts(m, key->description);7174 if (key_is_positive(key))···8582 struct request_key_auth *rka = dereference_key_locked(key);8683 size_t datalen;8784 long ret;8585+8686+ if (!rka)8787+ return -EKEYREVOKED;88888989 datalen = rka->callout_len;9090 ret = datalen;
+2-2
sound/pci/hda/hda_auto_parser.c
···824824 while (id >= 0) {825825 const struct hda_fixup *fix = codec->fixup_list + id;826826827827+ if (++depth > 10)828828+ break;827829 if (fix->chained_before)828830 apply_fixup(codec, fix->chain_id, action, depth + 1);829831···864862 break;865863 }866864 if (!fix->chained || fix->chained_before)867867- break;868868- if (++depth > 10)869865 break;870866 id = fix->chain_id;871867 }
+2-1
sound/pci/hda/hda_generic.c
···60096009 if (spec->init_hook)60106010 spec->init_hook(codec);6011601160126012- snd_hda_apply_verbs(codec);60126012+ if (!spec->skip_verbs)60136013+ snd_hda_apply_verbs(codec);6013601460146015 init_multi_out(codec);60156016 init_extra_out(codec);
+1
sound/pci/hda/hda_generic.h
···243243 unsigned int indep_hp_enabled:1; /* independent HP enabled */244244 unsigned int have_aamix_ctl:1;245245 unsigned int hp_mic_jack_modes:1;246246+ unsigned int skip_verbs:1; /* don't apply verbs at snd_hda_gen_init() */246247247248 /* additional mute flags (only effective with auto_mute_via_amp=1) */248249 u64 mute_bits;
···448448}449449450450/*451451+ * The test creates a cgroups and freezes it. Then it creates a child cgroup452452+ * and populates it with a task. After that it checks that the child cgroup453453+ * is frozen and the parent cgroup remains frozen too.454454+ */455455+static int test_cgfreezer_mkdir(const char *root)456456+{457457+ int ret = KSFT_FAIL;458458+ char *parent, *child = NULL;459459+ int pid;460460+461461+ parent = cg_name(root, "cg_test_mkdir_A");462462+ if (!parent)463463+ goto cleanup;464464+465465+ child = cg_name(parent, "cg_test_mkdir_B");466466+ if (!child)467467+ goto cleanup;468468+469469+ if (cg_create(parent))470470+ goto cleanup;471471+472472+ if (cg_freeze_wait(parent, true))473473+ goto cleanup;474474+475475+ if (cg_create(child))476476+ goto cleanup;477477+478478+ pid = cg_run_nowait(child, child_fn, NULL);479479+ if (pid < 0)480480+ goto cleanup;481481+482482+ if (cg_wait_for_proc_count(child, 1))483483+ goto cleanup;484484+485485+ if (cg_check_frozen(child, true))486486+ goto cleanup;487487+488488+ if (cg_check_frozen(parent, true))489489+ goto cleanup;490490+491491+ ret = KSFT_PASS;492492+493493+cleanup:494494+ if (child)495495+ cg_destroy(child);496496+ free(child);497497+ if (parent)498498+ cg_destroy(parent);499499+ free(parent);500500+ return ret;501501+}502502+503503+/*451504 * The test creates two nested cgroups, freezes the parent452505 * and removes the child. Then it checks that the parent cgroup453506 * remains frozen and it's possible to create a new child···868815 T(test_cgfreezer_simple),869816 T(test_cgfreezer_tree),870817 T(test_cgfreezer_forkbomb),818818+ T(test_cgfreezer_mkdir),871819 T(test_cgfreezer_rmdir),872820 T(test_cgfreezer_migrate),873821 T(test_cgfreezer_ptrace),
+13-11
tools/testing/selftests/net/fib_nexthops.sh
···212212 printf " ${out}\n"213213 printf " Expected:\n"214214 printf " ${expected}\n\n"215215+ else216216+ echo " WARNING: Unexpected route entry"215217 fi216218 fi217219···276274277275 run_cmd "$IP nexthop get id 52"278276 log_test $? 0 "Get nexthop by id"279279- check_nexthop "id 52" "id 52 via 2001:db8:91::2 dev veth1"277277+ check_nexthop "id 52" "id 52 via 2001:db8:91::2 dev veth1 scope link"280278281279 run_cmd "$IP nexthop del id 52"282280 log_test $? 0 "Delete nexthop by id"···481479 run_cmd "$IP -6 nexthop add id 85 dev veth1"482480 run_cmd "$IP ro replace 2001:db8:101::1/128 nhid 85"483481 log_test $? 0 "IPv6 route with device only nexthop"484484- check_route6 "2001:db8:101::1" "2001:db8:101::1 nhid 85 dev veth1"482482+ check_route6 "2001:db8:101::1" "2001:db8:101::1 nhid 85 dev veth1 metric 1024 pref medium"485483486484 run_cmd "$IP nexthop add id 123 group 81/85"487485 run_cmd "$IP ro replace 2001:db8:101::1/128 nhid 123"488486 log_test $? 0 "IPv6 multipath route with nexthop mix - dev only + gw"489489- check_route6 "2001:db8:101::1" "2001:db8:101::1 nhid 85 nexthop via 2001:db8:91::2 dev veth1 nexthop dev veth1"487487+ check_route6 "2001:db8:101::1" "2001:db8:101::1 nhid 123 metric 1024 nexthop via 2001:db8:91::2 dev veth1 weight 1 nexthop dev veth1 weight 1 pref medium"490488491489 #492490 # IPv6 route with v4 nexthop - not allowed···540538541539 run_cmd "$IP nexthop get id 12"542540 log_test $? 0 "Get nexthop by id"543543- check_nexthop "id 12" "id 12 via 172.16.1.2 src 172.16.1.1 dev veth1 scope link"541541+ check_nexthop "id 12" "id 12 via 172.16.1.2 dev veth1 scope link"544542545543 run_cmd "$IP nexthop del id 12"546544 log_test $? 0 "Delete nexthop by id"···687685 set +e688686 run_cmd "$IP ro add 172.16.101.1/32 nhid 11"689687 log_test $? 0 "IPv6 nexthop with IPv4 route"690690- check_route "172.16.101.1" "172.16.101.1 nhid 11 via ${lladdr} dev veth1"688688+ check_route "172.16.101.1" "172.16.101.1 nhid 11 via inet6 ${lladdr} dev veth1"691689692690 set -e693691 run_cmd "$IP nexthop add id 12 via 172.16.1.2 dev veth1"···696694 run_cmd "$IP ro replace 172.16.101.1/32 nhid 101"697695 log_test $? 0 "IPv6 nexthop with IPv4 route"698696699699- check_route "172.16.101.1" "172.16.101.1 nhid 101 nexthop via ${lladdr} dev veth1 weight 1 nexthop via 172.16.1.2 dev veth1 weight 1"697697+ check_route "172.16.101.1" "172.16.101.1 nhid 101 nexthop via inet6 ${lladdr} dev veth1 weight 1 nexthop via 172.16.1.2 dev veth1 weight 1"700698701699 run_cmd "$IP ro replace 172.16.101.1/32 via inet6 ${lladdr} dev veth1"702700 log_test $? 0 "IPv4 route with IPv6 gateway"703703- check_route "172.16.101.1" "172.16.101.1 via ${lladdr} dev veth1"701701+ check_route "172.16.101.1" "172.16.101.1 via inet6 ${lladdr} dev veth1"704702705703 run_cmd "$IP ro replace 172.16.101.1/32 via inet6 2001:db8:50::1 dev veth1"706704 log_test $? 2 "IPv4 route with invalid IPv6 gateway"···787785 log_test $? 0 "IPv4 route with device only nexthop"788786 check_route "172.16.101.1" "172.16.101.1 nhid 85 dev veth1"789787790790- run_cmd "$IP nexthop add id 122 group 21/85"791791- run_cmd "$IP ro replace 172.16.101.1/32 nhid 122"788788+ run_cmd "$IP nexthop add id 123 group 21/85"789789+ run_cmd "$IP ro replace 172.16.101.1/32 nhid 123"792790 log_test $? 0 "IPv4 multipath route with nexthop mix - dev only + gw"793793- check_route "172.16.101.1" "172.16.101.1 nhid 85 nexthop via 172.16.1.2 dev veth1 nexthop dev veth1"791791+ check_route "172.16.101.1" "172.16.101.1 nhid 123 nexthop via 172.16.1.2 dev veth1 weight 1 nexthop dev veth1 weight 1"794792795793 #796794 # IPv4 with IPv6···822820 run_cmd "$IP ro replace 172.16.101.1/32 nhid 101"823821 log_test $? 0 "IPv4 route with mixed v4-v6 multipath route"824822825825- check_route "172.16.101.1" "172.16.101.1 nhid 101 nexthop via ${lladdr} dev veth1 weight 1 nexthop via 172.16.1.2 dev veth1 weight 1"823823+ check_route "172.16.101.1" "172.16.101.1 nhid 101 nexthop via inet6 ${lladdr} dev veth1 weight 1 nexthop via 172.16.1.2 dev veth1 weight 1"826824827825 run_cmd "ip netns exec me ping -c1 -w1 172.16.101.1"828826 log_test $? 0 "IPv6 nexthop with IPv4 route"
+7
tools/testing/selftests/net/xfrm_policy.sh
···106106 #107107 # 10.0.0.0/24 and 10.0.1.0/24 nodes have been merged as 10.0.0.0/23.108108 ip -net $ns xfrm policy add src 10.1.0.0/24 dst 10.0.0.0/23 dir fwd priority 200 action block109109+110110+ # similar to above: add policies (with partially random address), with shrinking prefixes.111111+ for p in 29 28 27;do112112+ for k in $(seq 1 32); do113113+ ip -net $ns xfrm policy add src 10.253.1.$((RANDOM%255))/$p dst 10.254.1.$((RANDOM%255))/$p dir fwd priority $((200+k)) action block 2>/dev/null114114+ done115115+ done109116}110117111118do_esp_policy_get_check() {