# [Solved] Custom Kernel and Drivers + Virtualization

## rabcor

Long story short, I've been playing around with the concept of VGA-Passthrough.

I have a very specific setup in mind, but I need to be able to use and update a highly customized kernel (Gentoos strongest point right?) this involves both custom configurations and a patch (ACS Override)

I will also need to patch the Nvidia proprietary drivers which I have absolutely no idea how to do so.

This is specifically what I'm trying to do with the above.

How do I apply these patches in gentoo? Is there any way to automate the process so I don't have to worry about it when I update the kernel/drivers?

----------

## rabcor

Come on guys, nobody? I really need to get this done   :Sad: 

I've never really done patching before, not by hand anyhow

----------

## chithanh

It's called "Applying non-standard patches" and is documented in the handbook: http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=3&chap=6#doc_chap6

Basically, you copy your patch to an aptly named subdirectory of /etc/portage/patches and it will be applied automatically. A few packages don't support it though.

----------

## rabcor

Thanks! That's super easy. The Nvidia driver patch just simply worked.  But the ACS override patch fails when I try to emerge gentoo-sources. Could someone help me find out exactly where it fails?

I copied it from the page starting at

 *Quote:*   

> 
> 
> ---- 
> 
> Documentation/kernel-parameters.txt |   10 +++
> ...

 

This is the output

```

***** ACS_Override.patch *****

PWD: /var/tmp/portage/sys-kernel/gentoo-sources-3.14.4/work/linux-3.14.4-gentoo

==============================

PATCH COMMAND:  patch -p0 -g0 -E --no-backup-if-mismatch  < '/etc/portage/patches/sys-kernel/gentoo-sources/ACS_Override.patch'

==============================

can't find file to patch at input line 9

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|---

| Documentation/kernel-parameters.txt |   10 +++

| drivers/pci/quirks.c                |  102 +++++++++++++++++++++++++++++++++++

| 2 files changed, 112 insertions(+)

|diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt

|index 47bb23c..a60e6ad 100644

|--- a/Documentation/kernel-parameters.txt

|+++ b/Documentation/kernel-parameters.txt

--------------------------

No file to patch.  Skipping patch.

1 out of 1 hunk ignored

can't find file to patch at input line 30

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c

|index 0369fb6..c7609f6 100644

|--- a/drivers/pci/quirks.c

|+++ b/drivers/pci/quirks.c

--------------------------

No file to patch.  Skipping patch.

patch unexpectedly ends in middle of line

1 out of 1 hunk ignored

patch program exited with status 1

```

I have no idea what to do here

It fails at these lines: (but thats the only thing I really know, I don't know how to fix this)

```

9: @@ -2349,6 +2349,16 @@ bytes respectively. Such letter suffixes can also be entirely omitted.

30: @@ -3292,11 +3292,113 @@ struct pci_dev *pci_get_dma_source(struct pci_dev *dev)

```

----------

## rabcor

Solved it, anyone interested can find my updated ACS Override patch here.

My first time making a patch with diff, but it seems to have worked   :Wink:  all I have to do now is test it, and for this I need to recompile a bit.

----------

## feniksa

In case, if someone still interesting in patch, I support patch for stable versions of kernel

I support acs override patch for stable kernel https://github.com/feniksa/gentoo_ACS_override_patch

If someone need ACS patch for gentoo:

1. Clone repo: git clone https://github.com/feniksa/gentoo_ACS_override_patch

2. Put files to /etc/portage/patches

3. Re-emerge gentoo-sources package

4. Re-build kernel

----------

